about summary refs log tree commit diff
path: root/nq.c
diff options
context:
space:
mode:
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) {