Browse Source

* fix for 19114. Deal with empty arguments more graciously by quoting them.

git-svn-id: trunk@17272 -
marco 14 years ago
parent
commit
f34ffd02c9
1 changed files with 7 additions and 3 deletions
  1. 7 3
      rtl/linux/system.pp

+ 7 - 3
rtl/linux/system.pp

@@ -33,7 +33,7 @@ Unit System;
 
 
 {$I sysunixh.inc}
 {$I sysunixh.inc}
 
 
-function get_cmdline:Pchar;
+function get_cmdline:Pchar; 
 property cmdline:Pchar read get_cmdline;
 property cmdline:Pchar read get_cmdline;
 
 
 {$if defined(CPUARM) or defined(CPUM68K)}
 {$if defined(CPUARM) or defined(CPUM68K)}
@@ -179,6 +179,7 @@ begin
          found:=true;
          found:=true;
          break;
          break;
        end;
        end;
+     found:=found or (len=0); // also quote if len=0, bug 19114
      if bufsize+len>=ARG_MAX-2 then
      if bufsize+len>=ARG_MAX-2 then
       AddBuf;
       AddBuf;
      if found then
      if found then
@@ -186,8 +187,11 @@ begin
         buf[bufsize]:='"';
         buf[bufsize]:='"';
         inc(bufsize);
         inc(bufsize);
       end;
       end;
-     move(argv[i]^,buf[bufsize],len);
-     inc(bufsize,len);
+     if len>0 then
+       begin
+         move(argv[i]^,buf[bufsize],len);
+         inc(bufsize,len);
+       end;
      if found then
      if found then
       begin
       begin
         buf[bufsize]:='"';
         buf[bufsize]:='"';