diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-06 20:46:46 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-06 20:46:46 +0200 |
commit | 17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3 (patch) | |
tree | ee740b30e4f33d7e9eaa6b10b225ec7b65de7196 /nq.c | |
parent | 308cc51f5df0341001b1e1b0aa63ab08d2376c0c (diff) | |
download | nq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.tar.gz nq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.tar.xz nq-17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3.zip |
nq: use snprintf
Diffstat (limited to 'nq.c')
-rw-r--r-- | nq.c | 9 |
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) { |