summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-08 14:41:36 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-08 14:41:36 +0000
commit0dd747760e31a52573e554196cc12d13c8834233 (patch)
tree87dae4e446747d1cef450df2b8f7216179419efe
parent1742b57c92e08d4ed49f598399a126761720b70f (diff)
downloadfpc-0dd747760e31a52573e554196cc12d13c8834233.tar.gz
* fix for 19114. Deal with empty arguments more graciously by quoting them.
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17272 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/linux/system.pp10
1 files changed, 7 insertions, 3 deletions
diff --git a/rtl/linux/system.pp b/rtl/linux/system.pp
index 6508aa42ad..9aae64619e 100644
--- a/rtl/linux/system.pp
+++ b/rtl/linux/system.pp
@@ -33,7 +33,7 @@ Unit System;
{$I sysunixh.inc}
-function get_cmdline:Pchar;
+function get_cmdline:Pchar;
property cmdline:Pchar read get_cmdline;
{$if defined(CPUARM) or defined(CPUM68K)}
@@ -179,6 +179,7 @@ begin
found:=true;
break;
end;
+ found:=found or (len=0); // also quote if len=0, bug 19114
if bufsize+len>=ARG_MAX-2 then
AddBuf;
if found then
@@ -186,8 +187,11 @@ begin
buf[bufsize]:='"';
inc(bufsize);
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
begin
buf[bufsize]:='"';