summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-30 11:18:44 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-30 11:18:44 -0700
commit704beb71768cdaa2448da6edfa219b4a7bf862f1 (patch)
tree31646078d37ccee89d9bb89019ae3cad7e58559f
parent3038a87edce31ad2895431f7cfdc96a33fc70e02 (diff)
Replace strcpy+strcat pairs with snprintf calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--AuFileName.c7
-rw-r--r--AuLock.c6
-rw-r--r--AuUnlock.c6
3 files changed, 7 insertions, 12 deletions
diff --git a/AuFileName.c b/AuFileName.c
index 473fad1..0904273 100644
--- a/AuFileName.c
+++ b/AuFileName.c
@@ -57,9 +57,8 @@ XauFileName (void)
name = getenv ("HOME");
if (!name) {
#ifdef WIN32
- (void) strcpy (dir, "/users/");
if ((name = getenv("USERNAME"))) {
- (void) strcat (dir, name);
+ snprintf(dir, sizeof(dir), "/users/%s", name);
name = dir;
}
if (!name)
@@ -81,7 +80,7 @@ XauFileName (void)
bsize = size;
}
- strcpy (buf, name);
- strcat (buf, slashDotXauthority + (name[1] == '\0' ? 1 : 0));
+ snprintf (buf, bsize, "%s%s", name,
+ slashDotXauthority + (name[1] == '\0' ? 1 : 0));
return buf;
}
diff --git a/AuLock.c b/AuLock.c
index b9859f1..ce15f25 100644
--- a/AuLock.c
+++ b/AuLock.c
@@ -55,10 +55,8 @@ long dead)
if (strlen (file_name) > 1022)
return LOCK_ERROR;
- (void) strcpy (creat_name, file_name);
- (void) strcat (creat_name, "-c");
- (void) strcpy (link_name, file_name);
- (void) strcat (link_name, "-l");
+ snprintf (creat_name, sizeof(creat_name), "%s-c", file_name);
+ snprintf (link_name, sizeof(link_name), "%s-l", file_name);
if (stat (creat_name, &statb) != -1) {
now = time ((Time_t *) 0);
/*
diff --git a/AuUnlock.c b/AuUnlock.c
index ddbe7db..309ba6d 100644
--- a/AuUnlock.c
+++ b/AuUnlock.c
@@ -42,11 +42,9 @@ _Xconst char *file_name)
if (strlen (file_name) > 1022)
return 0;
#ifndef WIN32
- (void) strcpy (creat_name, file_name);
- (void) strcat (creat_name, "-c");
+ snprintf (creat_name, sizeof(creat_name), "%s-c", file_name);
#endif
- (void) strcpy (link_name, file_name);
- (void) strcat (link_name, "-l");
+ snprintf (link_name, sizeof(link_name), "%s-l", file_name);
/*
* I think this is the correct order
*/