From 17c5dbc0f553b04dd0815c3da2a17cf1a0cc4ef3 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Thu, 6 Aug 2015 20:46:46 +0200 Subject: nq: use snprintf --- nq.c | 9 ++++++--- 1 file 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) { -- cgit 1.4.1