From a051bab859d36159b313fef9e57f41d1068dc948 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Thu, 23 Jun 2011 02:08:41 +0100 Subject: [PATCH] enmasse: check filename length --- LICENSE | 1 + util/enmasse.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 333f75d..e4f2330 100644 --- a/LICENSE +++ b/LICENSE @@ -6,6 +6,7 @@ MIT/X Consortium License © 2011 Rob Pilling © 2011 Hiltjo Posthuma © 2011 pancake +© 2011 Random832 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/util/enmasse.c b/util/enmasse.c index 6136c45..dbbbdbb 100644 --- a/util/enmasse.c +++ b/util/enmasse.c @@ -21,17 +21,16 @@ enmasse(int argc, char **argv, int (*fn)(const char *, const char *)) fnck(argv[0], argv[1], fn); return; } - else if(argc == 1) - dir = "."; else - dir = argv[--argc]; + dir = (argc == 1) ? "." : argv[--argc]; if((size = pathconf(dir, _PC_PATH_MAX)) == -1) size = BUFSIZ; if(!(buf = malloc(size))) eprintf("malloc:"); for(i = 0; i < argc; i++) { - snprintf(buf, size, "%s/%s", dir, basename(argv[i])); + if(snprintf(buf, size, "%s/%s", dir, basename(argv[i])) > size) + eprintf("%s/%s: filename too long\n", dir, basename(argv[i])); fnck(argv[i], buf, fn); } free(buf);