summaryrefslogtreecommitdiff
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2001-08-21 11:39:32 +0000
committerBrian Somers <brian@FreeBSD.org>2001-08-21 11:39:32 +0000
commit081f2a7ec67e3bdfb294ba8c76ca2abba9e065e0 (patch)
tree9d4fd0ecdbfe74ad84e5c3250ad4bdd49537cdda /usr.bin/ftp
parent468fe0fdf1c46bc98d1800bd7fb9e8a054eefa7a (diff)
downloadsrc-test-081f2a7ec67e3bdfb294ba8c76ca2abba9e065e0.tar.gz
src-test-081f2a7ec67e3bdfb294ba8c76ca2abba9e065e0.zip
Handle overflows from snprintf(), not just returns of < 0
Pointed out by: bde
Notes
Notes: svn path=/head/; revision=82054
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 1936baf3c14e5..89f16f5e9ae24 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -624,7 +624,7 @@ progressmeter(flag)
ratio = MAX(ratio, 0);
ratio = MIN(ratio, 100);
n = snprintf(buf + len, sizeof(buf) - len, "\r%3d%% ", ratio);
- if (n > 0)
+ if (n > 0 || len < sizeof(buf) - len)
len += n;
barlength = ttywidth - 30;
@@ -635,7 +635,7 @@ progressmeter(flag)
"*****************************************************************************"
"*****************************************************************************",
barlength - i, "");
- if (n > 0)
+ if (n > 0 || len < sizeof(buf) - len)
len += n;
}
@@ -648,7 +648,7 @@ progressmeter(flag)
n = snprintf(buf + len, sizeof(buf) - len,
" %5qd %c%c ", (long long)abbrevsize, prefixes[i],
prefixes[i] == ' ' ? ' ' : 'B');
- if (n > 0)
+ if (n > 0 || len < sizeof(buf) - len)
len += n;
timersub(&now, &lastupdate, &wait);
@@ -685,14 +685,14 @@ progressmeter(flag)
else
n = snprintf(buf + len, sizeof(buf) - len,
" ");
- if (n > 0)
+ if (n > 0 || len < sizeof(buf) - len)
len += n;
i = remaining % SECSPERHOUR;
len += snprintf(buf + len, sizeof(buf) - len,
"%02d:%02d ETA", i / 60, i % 60);
}
}
- if (n > 0)
+ if (n > 0 || len < sizeof(buf) - len)
len += n;
(void)write(STDOUT_FILENO, buf, len);