mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-13 14:29:20 +03:00
File fetcher: Avoid atoi for If-None-Match value parse.
The file fetcher emits FETCH_NOTMODIFIED if the file is unchanged.
This commit is contained in:
parent
c92b31babe
commit
b15cbb72ac
@ -50,6 +50,8 @@
|
|||||||
#include "utils/corestrings.h"
|
#include "utils/corestrings.h"
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
#include "utils/log.h"
|
||||||
|
#include "utils/time.h"
|
||||||
#include "utils/ring.h"
|
#include "utils/ring.h"
|
||||||
#include "utils/file.h"
|
#include "utils/file.h"
|
||||||
#include "netsurf/fetch.h"
|
#include "netsurf/fetch.h"
|
||||||
@ -156,18 +158,25 @@ fetch_file_setup(struct fetch *fetchh,
|
|||||||
|
|
||||||
/* Scan request headers looking for If-None-Match */
|
/* Scan request headers looking for If-None-Match */
|
||||||
for (i = 0; headers[i] != NULL; i++) {
|
for (i = 0; headers[i] != NULL; i++) {
|
||||||
if (strncasecmp(headers[i], "If-None-Match:",
|
if (strncasecmp(headers[i], "If-None-Match:",
|
||||||
SLEN("If-None-Match:")) == 0) {
|
SLEN("If-None-Match:")) != 0) {
|
||||||
/* If-None-Match: "12345678" */
|
continue;
|
||||||
const char *d = headers[i] + SLEN("If-None-Match:");
|
}
|
||||||
|
|
||||||
/* Scan to first digit, if any */
|
/* If-None-Match: "12345678" */
|
||||||
while (*d != '\0' && (*d < '0' || '9' < *d))
|
const char *d = headers[i] + SLEN("If-None-Match:");
|
||||||
d++;
|
|
||||||
|
|
||||||
/* Convert to time_t */
|
/* Scan to first digit, if any */
|
||||||
if (*d != '\0')
|
while (*d != '\0' && (*d < '0' || '9' < *d))
|
||||||
ctx->file_etag = atoi(d);
|
d++;
|
||||||
|
|
||||||
|
/* Convert to time_t */
|
||||||
|
if (*d != '\0') {
|
||||||
|
ret = nsc_snptimet(d, strlen(d), &ctx->file_etag);
|
||||||
|
if (ret != NSERROR_OK) {
|
||||||
|
NSLOG(fetch, WARNING,
|
||||||
|
"Bad If-None-Match value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user