snprintf() returns the # of chars printed *excluding* '\0'

This commit is contained in:
sin 2014-01-24 16:23:13 +00:00
parent 30620afb6c
commit b58951b4f0
2 changed files with 3 additions and 3 deletions

View File

@ -40,13 +40,13 @@ cp(const char *s1, const char *s2)
if(strcmp(d->d_name, ".")
&& strcmp(d->d_name, "..")) {
if(snprintf(ns1, size1, "%s/%s", s1,
d->d_name) > size1) {
d->d_name) >= size1) {
eprintf("%s/%s: filename too long\n",
s1, d->d_name);
}
if(snprintf(ns2, size2, "%s/%s", s2,
d->d_name) > size2) {
d->d_name) >= size2) {
eprintf("%s/%s: filename too long\n",
s2, d->d_name);
}

View File

@ -26,7 +26,7 @@ enmasse(int argc, char **argv, int (*fn)(const char *, const char *))
apathmax(&buf, &size);
for(i = 0; i < argc; i++) {
if(snprintf(buf, size, "%s/%s", dir, basename(argv[i])) > size) {
if(snprintf(buf, size, "%s/%s", dir, basename(argv[i])) >= size) {
eprintf("%s/%s: filename too long\n", dir,
basename(argv[i]));
}