mirror of
git://git.suckless.org/sbase
synced 2024-12-22 15:04:53 +00:00
enmasse: check filename length
This commit is contained in:
parent
807d45aa80
commit
a051bab859
1
LICENSE
1
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"),
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user