aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2021-08-24 18:00:47 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2021-08-24 18:00:47 +0000
commit060510ba8bfba7a59908fb5aa99aa8d17d6882c8 (patch)
tree4ceb48fdf87d937741a2bdcfbedddf7f68a004d3
parentc8a2cc4ba845333c122fb6d86ee7430a01cc397e (diff)
Fix libfetch out of bounds read.
Approved by: so Security: SA-21:15.libfetch Security: CVE-2021-36159
-rw-r--r--lib/libfetch/ftp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index 9a546f3fecad..dfde6edce734 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -704,8 +704,11 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file,
goto ouch;
}
l = (e == FTP_PASSIVE_MODE ? 6 : 21);
- for (i = 0; *p && i < l; i++, p++)
+ for (i = 0; *p && i < l; i++, p++) {
addr[i] = strtol(p, &p, 10);
+ if (*p == '\0' && i < l - 1)
+ break;
+ }
if (i < l) {
e = FTP_PROTOCOL_ERROR;
goto ouch;