Ken McDonell wrote:
...
commit 00d426e80b1ef2faf98b7a5cc13f705acee3b053
Author: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Fri Jan 16 17:09:43 2009 +1100
Avoid updating pointer array allocated to static data.
Exposed by newer gcc, need to change default (host) and alternate
(archive) logic to set argv[] in kmServerExec().
Just curious how this ever worked with any (current or previous) compiler?
I thought const strings were placed in a read-only data segment, so the
assignment argv[1][1] = 'h' should have consistently faulted?
Cheers
diff --git a/src/libkmtime/src/client.c b/src/libkmtime/src/client.c
index 8f9e01d..43a8e5f 100644
--- a/src/libkmtime/src/client.c
+++ b/src/libkmtime/src/client.c
@@ -23,10 +23,12 @@ static int kmServerExec(int fd, int livemode)
{
char portname[32];
int port, in, out;
- char *argv[] = { "kmtime", "-a", NULL };
+ char *argv[] = { "kmtime", NULL, NULL };
if (livemode)
- argv[1][1] = 'h'; /* -h for live hosts */
+ argv[1] = "-h"; /* -h for live hosts */
+ else
+ argv[1] = "-a"; /* -a for archives */
if (__pmProcessCreate(argv, &in, &out) == (pid_t)-1) {
__pmCloseSocket(fd);
|