mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
improve negative Content-length handling
This commit is contained in:
1 parent
45e4b3c423
commit
26699914cc
6 files changed
+95
-102
No files matched your search
@@ -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') {
|
||||
|
||||
Reference in new issue
Block a user