summaryrefslogtreecommitdiff
path: root/6/main.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-01-15 17:23:55 -0500
committerOri Bernstein <ori@eigenstate.org>2015-01-15 17:23:55 -0500
commit123ae8f453ef8add7d8abe42975066ec15f81a57 (patch)
tree3f37e9b79fed4b8f9672bf740934da329db64259 /6/main.c
parentc88028d9a01bb86e4002efbeedb06199f55300ac (diff)
downloadmc-123ae8f453ef8add7d8abe42975066ec15f81a57.tar.gz
Guaranteed termination: snprintf() vs strncpy().
strncpy() is crappy.
Diffstat (limited to '6/main.c')
-rw-r--r--6/main.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/6/main.c b/6/main.c
index 9918e07..f328479 100644
--- a/6/main.c
+++ b/6/main.c
@@ -53,10 +53,8 @@ static void swapout(char* buf, size_t sz, char* suf) {
psuffix = strrchr(outfile, '.');
if (psuffix != NULL)
swapsuffix(buf, sz, outfile, psuffix, suf);
- else {
- strncpy(buf, outfile, sz);
- strncat(buf, suf, sz);
- }
+ else
+ snprintf(buf, sz, "%s%s", outfile, suf);
}
static void assemble(char *asmsrc, char *path)