From 9266375e50fed6828c2b4ec27e77c3a84e1c3d13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Malo?= Date: Tue, 25 May 2004 19:09:45 +0000 Subject: [PATCH] parse byteranges correctly using the new apr_strtoff function git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103765 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_protocol.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index a8ffa87173..7020018bd6 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2788,6 +2788,8 @@ static int parse_byterange(char *range, apr_off_t clength, apr_off_t *start, apr_off_t *end) { char *dash = strchr(range, '-'); + char *errp; + apr_off_t number; if (!dash) { return 0; @@ -2795,15 +2797,23 @@ static int parse_byterange(char *range, apr_off_t clength, if ((dash == range)) { /* In the form "-5" */ - *start = clength - apr_atoi64(dash + 1); + if (apr_strtoff(&number, dash+1, &errp, 10) || *errp) { + return 0; + } + *start = clength - number; *end = clength - 1; } else { - *dash = '\0'; - dash++; - *start = apr_atoi64(range); + *dash++ = '\0'; + if (apr_strtoff(&number, range, &errp, 10) || *errp) { + return 0; + } + *start = number; if (*dash) { - *end = apr_atoi64(dash); + if (apr_strtoff(&number, dash, &errp, 10) || *errp) { + return 0; + } + *end = number; } else { /* "5-" */ *end = clength - 1; -- 2.50.1