From a623e17d6a09e634b929517f5374f8bc5d643e0f Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Mon, 23 Apr 2012 21:22:03 +0000 Subject: Handle HTTP Content-Length headers with trailing whitespace. ok martynas@ --- usr.bin/ftp/fetch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 9dd8489234a..bfa1b822a7c 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.103 2010/08/25 20:32:37 martynas Exp $ */ +/* $OpenBSD: fetch.c,v 1.104 2012/04/23 21:22:02 sthen Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -746,7 +746,10 @@ again: cp = buf; #define CONTENTLEN "Content-Length: " if (strncasecmp(cp, CONTENTLEN, sizeof(CONTENTLEN) - 1) == 0) { + size_t s; cp += sizeof(CONTENTLEN) - 1; + if (s=strcspn(cp, " \t")) + *(cp+s) = 0; filesize = strtonum(cp, 0, LLONG_MAX, &errstr); if (errstr != NULL) goto improper; -- cgit v1.2.3