* src/pic16/main.c (_pic16_finaliseOptions): do not quote the
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Nov 2008 00:16:33 +0000 (00:16 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Nov 2008 00:16:33 +0000 (00:16 +0000)
  argument of --asm= or --link= to allow for
  --asm="sh script --options", the user can double quote the
  argument if needed: --asm="'c:/program files/gpasm' -q",
  also fix some potential buffer overflows

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5274 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic16/main.c

index ec47b2203653a7488c1f8c00b689db3faaf33515..3d2a22a6cb10c880b7477750790a533ddb63e170 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-24 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/main.c (_pic16_finaliseOptions): do not quote the
+         argument of --asm= or --link= to allow for
+         --asm="sh script --options", the user can double quote the
+         argument if needed: --asm="'c:/program files/gpasm' -q",
+         also fix some potential buffer overflows
+
 2008-11-19 Borut Razem <borut.razem AT siol.net>
 
        * doc/sdccman.lyx:
index bd4a7e49ae01a0b2f70899f1ad418929d2ace75a..3a5de295e19c0fee3126087970afd3092ecf2863 100644 (file)
@@ -765,33 +765,55 @@ _pic16_finaliseOptions (void)
       size_t len = strlen(alt_asm);
       char *cmd = malloc(len + 3);
 
-      cmd[0] = '"';
-      memcpy(&cmd[1], alt_asm, len);
-      cmd[len + 1] = '"';
-      cmd[len + 2] = '\0';
-      pic16_linkCmd[0] = cmd;
+      if (0)
+        {
+          // fails for --asm="/bin/sh script.sh --options"
+          cmd[0] = '"';
+          memcpy(&cmd[1], alt_asm, len);
+          cmd[len + 1] = '"';
+          cmd[len + 2] = '\0';
+        }
+      else
+        {
+          // requires --asm="'my prog with spaces'"
+          memcpy(&cmd[0], alt_asm, len);
+          cmd[len] = 0;
+        }
+      pic16_asmCmd[0] = cmd;
     }
 
   if (alt_link && alt_link[0] != '\0')
     {
-      size_t len = strlen(alt_asm);
+      size_t len = strlen(alt_link);
       char *cmd = malloc(len + 3);
 
-      cmd[0] = '"';
-      memcpy(&cmd[1], alt_link, len);
-      cmd[len + 1] = '"';
-      cmd[len + 2] = '\0';
+      if (0)
+        {
+          // fails for --link="/bin/sh script.sh --options"
+          cmd[0] = '"';
+          memcpy(&cmd[1], alt_link, len);
+          cmd[len + 1] = '"';
+          cmd[len + 2] = '\0';
+        }
+      else
+        {
+          // requires --link="'my prog with spaces'"
+          memcpy(&cmd[0], alt_link, len);
+          cmd[len] = 0;
+        }
       pic16_linkCmd[0] = cmd;
     }
 
-  if  (!pic16_options.no_crt)
+  if (!pic16_options.no_crt)
     {
       pic16_options.omit_ivt = 1;
       pic16_options.leave_reset = 0;
     }
 
-  if  (options.model == MODEL_SMALL)
-    addSet(&asmOptionsSet, Safe_strdup("-DSDCC_MODEL_SMALL"));
+  if (options.model == MODEL_SMALL)
+    {
+      addSet(&asmOptionsSet, Safe_strdup("-DSDCC_MODEL_SMALL"));
+    }
   else if(options.model == MODEL_LARGE)
     {
       char buf[128];
@@ -803,7 +825,7 @@ _pic16_finaliseOptions (void)
       addSet(&asmOptionsSet, Safe_strdup(buf));
     }
 
-  if  (STACK_MODEL_LARGE)
+  if (STACK_MODEL_LARGE)
     {
       addSet(&preArgvSet, Safe_strdup("-DSTACK_MODEL_LARGE"));
       addSet(&asmOptionsSet, Safe_strdup("-DSTACK_MODEL_LARGE"));