freebsd-ports/security/sha1collisiondetection/files/patch-src_main.c
Steve Wills 001939be42 security/sha1collisiondetection: update to 1.0.3
PR:		235444
Submitted by:	jharris@widomaker.com (maintainer)
2019-02-11 19:38:47 +00:00

22 lines
630 B
C

--- src/main.c.orig 2017-03-27 16:11:23 UTC
+++ src/main.c
@@ -9,6 +9,8 @@
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
+#include <limits.h> /* for NAME_MAX, max bytes in a file name */
+#include <assert.h> /* for assert() macro */
#include "sha1.h"
@@ -23,7 +25,9 @@ int main(int argc, char** argv)
if (argc < 2)
{
- printf("Usage: %s <file>\n", basename(argv[0]));
+assert (sizeof(buffer) >= NAME_MAX); /* reuse buffer[] for newly-POSIX-compliant, thread-safe basename() */
+ (void) strlcpy (buffer, argv[0], sizeof (buffer));
+ printf("Usage: %s <file>\n", basename(buffer));
return 1;
}