1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

Allow port numbers up to INT_MAX

Also return an error on overflow.
This commit is contained in:
Nick Wellnhofer 2020-10-17 18:03:09 +02:00
parent 46837d47d5
commit b46016b870

12
uri.c
View File

@ -11,6 +11,7 @@
#define IN_LIBXML
#include "libxml.h"
#include <limits.h>
#include <string.h>
#include <libxml/xmlmemory.h>
@ -329,9 +330,14 @@ xmlParse3986Port(xmlURIPtr uri, const char **str)
if (ISA_DIGIT(cur)) {
while (ISA_DIGIT(cur)) {
port = port * 10 + (*cur - '0');
if (port > 99999999)
port = 99999999;
int digit = *cur - '0';
if (port > INT_MAX / 10)
return(1);
port *= 10;
if (port > INT_MAX - digit)
return(1);
port += digit;
cur++;
}