From 11d03dc86a9642a4af44c40122299b7efad47775 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Wed, 20 May 2020 14:01:17 +0000 Subject: core,modules: provide/use ap_parse_strict_length() helper. It helps simplifying a lot of duplicated code based on apr_strtoff(), while also rejecting leading plus/minus signs which are dissalowed in Content-Length and (Content-)Range headers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877954 13f79535-47bb-0310-9956-ffa450edef68 --- modules/mappers/mod_negotiation.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'modules/mappers') diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index dc0211487c..c056b28455 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -988,19 +988,17 @@ static int read_type_map(apr_file_t **map, negotiation_state *neg, has_content = 1; } else if (!strncmp(buffer, "content-length:", 15)) { - char *errp; - apr_off_t number; + apr_off_t clen; body1 = ap_get_token(neg->pool, &body, 0); - if (apr_strtoff(&number, body1, &errp, 10) != APR_SUCCESS - || *errp || number < 0) { + if (!ap_parse_strict_length(&clen, body1)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00684) "Parse error in type map, Content-Length: " "'%s' in %s is invalid.", body1, r->filename); break; } - mime_info.bytes = number; + mime_info.bytes = clen; has_content = 1; } else if (!strncmp(buffer, "content-language:", 17)) { -- cgit v1.2.3