aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r--xorg-server/os/utils.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 07cf4c24f..b49fd3251 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -258,7 +258,7 @@ LockServer(void)
*/
tmppath = LOCK_DIR;
- sprintf(port, "%d", atoi(display));
+ snprintf(port, sizeof(port), "%d", atoi(display));
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
strlen(LOCK_TMP_PREFIX);
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
@@ -295,7 +295,7 @@ LockServer(void)
}
if (lfd < 0)
FatalError("Could not create lock file in %s\n", tmp);
- (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+ snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long)getpid());
(void) write(lfd, pid_str, 11);
(void) fchmod(lfd, 0444);
(void) close(lfd);
@@ -1252,7 +1252,7 @@ OsAbort (void)
*/
int
-System(char *command)
+System(const char *command)
{
int pid, p;
void (*csig)(int);
@@ -1302,7 +1302,7 @@ static struct pid {
OsSigHandlerPtr old_alarm = NULL; /* XXX horrible awful hack */
pointer
-Popen(char *command, char *type)
+Popen(const char *command, const char *type)
{
struct pid *cur;
FILE *iop;
@@ -1388,7 +1388,7 @@ Popen(char *command, char *type)
/* fopen that drops privileges */
pointer
-Fopen(char *file, char *type)
+Fopen(const char *file, const char *type)
{
FILE *iop;
#ifndef HAS_SAVED_IDS_AND_SETEUID
@@ -1664,13 +1664,11 @@ CheckUserParameters(int argc, char **argv, char **envp)
if (!eq)
continue;
len = eq - envp[i];
- e = malloc(len + 1);
+ e = strndup(envp[i], len);
if (!e) {
bad = InternalError;
break;
}
- strncpy(e, envp[i], len);
- e[len] = 0;
if (len >= 4 &&
(strcmp(e + len - 4, "PATH") == 0 ||
strcmp(e, "TERMCAP") == 0)) {