improve negative Content-length handling

This commit is contained in:
Sergio R. Caprile committed 2023-05-22 17:40:08 -03:00
1 parent 45e4b3c423
commit 26699914cc
6 files changed
+95 -102

No files matched your search

-26
View File
@@ -187,32 +187,6 @@ void mg_unhex(const char *buf, size_t len, unsigned char *to) {
}
}
uint64_t mg_tou64(struct mg_str str) {
uint64_t result = 0;
size_t i = 0;
while (i < str.len && (str.ptr[i] == ' ' || str.ptr[i] == '\t')) i++;
while (i < str.len && str.ptr[i] >= '0' && str.ptr[i] <= '9') {
result *= 10;
result += (unsigned) (str.ptr[i] - '0');
i++;
}
return result;
}
int64_t mg_to64(struct mg_str str) {
int64_t result = 0, neg = 1, max = 922337203685477570 /* INT64_MAX/10-10 */;
size_t i = 0;
while (i < str.len && (str.ptr[i] == ' ' || str.ptr[i] == '\t')) i++;
if (i < str.len && str.ptr[i] == '-') neg = -1, i++;
while (i < str.len && str.ptr[i] >= '0' && str.ptr[i] <= '9') {
if (result > max) return 0;
result *= 10;
result += (str.ptr[i] - '0');
i++;
}
return result * neg;
}
char *mg_remove_double_dots(char *s) {
char *saved = s, *p = s;
while (*s != '\0') {