sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit a051bab859d36159b313fef9e57f41d1068dc948
parent 807d45aa80fb987571d76cd5b38b1011ed13d8c6
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Thu Jun 23 02:08:41 +0100

enmasse: check filename length
Diffstat:
LICENSE | 1+
util/enmasse.c | 7+++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/LICENSE b/LICENSE @@ -6,6 +6,7 @@ MIT/X Consortium License © 2011 Rob Pilling <robpilling@gmail.com> © 2011 Hiltjo Posthuma <hiltjo@codemadness.org> © 2011 pancake <pancake@youterm.com> +© 2011 Random832 <random832@fastmail.us> 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 @@ -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);