summaryrefslogtreecommitdiff
path: root/xinit.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2008-04-20 17:30:14 +0200
committerMatthieu Herrb <matthieu@reactor.herrb.net>2008-04-20 17:30:14 +0200
commitedc3112679af749f0c6fc54b2eec1b89aaf0d0c8 (patch)
tree829cf2896555731d437e9cff94cd59d571629665 /xinit.c
parent47d561fd6efb8923cfbace6fea40dfeb314b4662 (diff)
downloadxorg-app-xinit-edc3112679af749f0c6fc54b2eec1b89aaf0d0c8.tar.gz
Replace sprintf() and strcpy() with snprintf().
Diffstat (limited to 'xinit.c')
-rw-r--r--xinit.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/xinit.c b/xinit.c
index 61cd378..d8e7c47 100644
--- a/xinit.c
+++ b/xinit.c
@@ -412,10 +412,11 @@ main(int argc, char *argv[], char *envp[])
xinitrcbuf[0] = '\0';
if ((cp = getenv ("XINITRC")) != NULL) {
- strcpy (xinitrcbuf, cp);
+ (void) snprintf (xinitrcbuf, sizeof(xinitrcbuf), "%s", cp);
required = True;
} else if ((cp = getenv ("HOME")) != NULL) {
- (void) sprintf (xinitrcbuf, "%s/%s", cp, XINITRC);
+ (void) snprintf (xinitrcbuf, sizeof(xinitrcbuf),
+ "%s/%s", cp, XINITRC);
}
if (xinitrcbuf[0]) {
if (access (xinitrcbuf, F_OK) == 0) {
@@ -439,10 +440,11 @@ main(int argc, char *argv[], char *envp[])
xserverrcbuf[0] = '\0';
if ((cp = getenv ("XSERVERRC")) != NULL) {
- strcpy (xserverrcbuf, cp);
+ (void) snprintf (xserverrcbuf, sizeof(xserverrcbuf), "%s", cp);
required = True;
} else if ((cp = getenv ("HOME")) != NULL) {
- (void) sprintf (xserverrcbuf, "%s/%s", cp, XSERVERRC);
+ (void) snprintf (xserverrcbuf, sizeof(xserverrcbuf),
+ "%s/%s", cp, XSERVERRC);
}
if (xserverrcbuf[0]) {
if (access (xserverrcbuf, F_OK) == 0) {
@@ -705,6 +707,7 @@ setWindowPath(void)
unsigned long num;
char nums[10];
int numn;
+ size_t len;
prop = XInternAtom(xd, "XFree86_VT", False);
if (prop == None) {
#ifdef DEBUG
@@ -760,11 +763,18 @@ setWindowPath(void)
windowpath = getenv("WINDOWPATH");
numn = snprintf(nums, sizeof(nums), "%lu", num);
if (!windowpath) {
- newwindowpath = malloc(10 + 1 + numn + 1);
- sprintf(newwindowpath, "WINDOWPATH=%s", nums);
+ len = 10 + 1 + numn + 1;
+ newwindowpath = malloc(len);
+ if (newwindowpath == NULL)
+ return;
+ snprintf(newwindowpath, len, "WINDOWPATH=%s", nums);
} else {
- newwindowpath = malloc(10 + 1 + strlen(windowpath) + 1 + numn + 1);
- sprintf(newwindowpath, "WINDOWPATH=%s:%s", windowpath, nums);
+ len = 10 + 1 + strlen(windowpath) + 1 + numn + 1;
+ newwindowpath = malloc(len);
+ if (newwindowpath == NULL)
+ return;
+ snprintf(newwindowpath, len, "WINDOWPATH=%s:%s",
+ windowpath, nums);
}
*newenvironlast++ = newwindowpath;
*newenvironlast = NULL;
@@ -887,8 +897,7 @@ set_environment(void)
}
/* put DISPLAY=displayname as first element */
- strcpy (displaybuf, "DISPLAY=");
- strcpy (displaybuf + 8, displayNum);
+ snprintf (displaybuf, sizeof(displaybuf), "DISPLAY=%s", displayNum);
newPtr = newenviron;
*newPtr++ = displaybuf;