ref: 123ae8f453ef8add7d8abe42975066ec15f81a57
parent: c88028d9a01bb86e4002efbeedb06199f55300ac
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Jan 15 12:23:55 EST 2015
Guaranteed termination: snprintf() vs strncpy(). strncpy() is crappy.
--- a/6/main.c
+++ b/6/main.c
@@ -53,10 +53,8 @@
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)