diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-11-26 13:21:18 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-11-26 13:21:18 -0800 |
commit | 6f4560e2ad81736127d2d3544415a05d41e8a2a7 (patch) | |
tree | 6c53b2585d1081cf9296c09cd22acee1e9ac9a4f /restart.c | |
parent | fab9dcb15024996ac3a4f94d65ba73f484820534 (diff) |
Use snprintf, strdup & remove instead of sprintf, malloc/strcpy & unlink
Diffstat (limited to 'restart.c')
-rw-r--r-- | restart.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -247,7 +247,7 @@ Restart(int flag) * The client is being restarted on the local machine. */ - sprintf (logtext, "Restarting locally : "); + snprintf (logtext, sizeof(logtext), "Restarting locally : "); for (pp = args; *pp; pp++) { strcat (logtext, *pp); @@ -259,8 +259,8 @@ Restart(int flag) switch(fork()) { case -1: - sprintf (logtext, - "%s: Can't fork() %s", Argv[0], program); + snprintf (logtext, sizeof(logtext), + "%s: Can't fork() %s", Argv[0], program); add_log_text (logtext); perror (logtext); break; @@ -268,8 +268,8 @@ Restart(int flag) chdir(cwd); if(env) environ = env; execvp(program, args); - sprintf (logtext, "%s: Can't execvp() %s", - Argv[0], program); + snprintf (logtext, sizeof(logtext), + "%s: Can't execvp() %s", Argv[0], program); perror (logtext); /* * TODO : We would like to send this log information to the @@ -296,8 +296,8 @@ Restart(int flag) * The client is being restarted on a remote machine. */ - sprintf (logtext, "Restarting remotely on %s : ", - restart_machine); + snprintf (logtext, sizeof(logtext), + "Restarting remotely on %s : ", restart_machine); for (pp = args; *pp; pp++) { strcat (logtext, *pp); @@ -447,7 +447,8 @@ Clone(ClientRec *client, Bool useSavedState) switch(fork()) { case -1: - sprintf (msg, "%s: Can't fork() %s", Argv[0], program); + snprintf (msg, sizeof(msg), + "%s: Can't fork() %s", Argv[0], program); add_log_text (msg); perror (msg); break; @@ -455,7 +456,8 @@ Clone(ClientRec *client, Bool useSavedState) chdir(cwd); if(env) environ = env; execvp(program, args); - sprintf (msg, "%s: Can't execvp() %s", Argv[0], program); + snprintf (msg, sizeof(msg), + "%s: Can't execvp() %s", Argv[0], program); perror (msg); /* * TODO : We would like to send this log information to the @@ -528,7 +530,7 @@ StartDefaultApps (void) home = (char *) getenv ("HOME"); if (!home) home = "."; - sprintf (filename, "%s/.xsmstartup", home); + snprintf (filename, sizeof(filename), "%s/.xsmstartup", home); f = fopen (filename, "r"); @@ -556,7 +558,7 @@ StartDefaultApps (void) if ((p = strchr (buf, '\n'))) *p = '\0'; - sprintf (logtext, "Starting locally : %s\n", buf); + snprintf (logtext, sizeof(logtext), "Starting locally : %s\n", buf); add_log_text (logtext); len = strlen (buf); @@ -589,7 +591,7 @@ StartNonSessionAwareApps(void) * byte for this. */ - sprintf (logtext, "Restarting locally : %s\n", + snprintf (logtext, sizeof(logtext), "Restarting locally : %s\n", non_session_aware_clients[i]); add_log_text (logtext); |