summary refs log tree commit diff
path: root/nq.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-06 20:46:46 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-06 20:46:46 +0200
commit17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3 (patch)
treeee740b30e4f33d7e9eaa6b10b225ec7b65de7196 /nq.c
parent308cc51f5df0341001b1e1b0aa63ab08d2376c0c (diff)
downloadnq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.tar.gz
nq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.tar.xz
nq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.zip
nq: use snprintf
Diffstat (limited to 'nq.c')
-rw-r--r--nq.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/nq.c b/nq.c
index 9662560..5c1ac74 100644
--- a/nq.c
+++ b/nq.c
@@ -117,7 +117,8 @@ usage:
 	}
 
 	if (tflag || wflag) {
-		sprintf(lockfile, ".,%011" PRIx64 ".%d", ms, getpid());
+		snprintf(lockfile, sizeof lockfile,
+		    ".,%011" PRIx64 ".%d", ms, getpid());
 		goto wait;
 	}
 
@@ -151,7 +152,8 @@ usage:
 		int status;
 
 		/* output expected lockfile name.  */
-		sprintf(lockfile, ",%011" PRIx64 ".%d", ms, child);
+		snprintf(lockfile, sizeof lockfile,
+		    ",%011" PRIx64 ".%d", ms, child);
 		dprintf(1, "%s\n", lockfile);
 		close(0);
 		close(1);
@@ -183,7 +185,8 @@ usage:
 
 	/* create and lock lockfile.  since this cannot be done in one step,
 	   use a different filename first.  */
-	sprintf(lockfile, ".,%011" PRIx64 ".%d", ms, getpid());
+	snprintf(lockfile, sizeof lockfile,
+	    ".,%011" PRIx64 ".%d", ms, getpid());
 	lockfd = openat(dirfd, lockfile,
 	    O_CREAT | O_EXCL | O_RDWR | O_APPEND, 0600);
 	if (lockfd < 0) {