kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit bbb245654d89f844f801a7c5a1b9a0aaac7d319a
parent af5f416e6d535b1bb20caaad56c200d6f7276a23
Author: Joris Vink <joris@coders.se>
Date:   Tue, 13 Aug 2013 16:13:43 +0200

Pass the base for strtoll() to kore_strtonum(), breakage ensues if we depend on the "auto" detection that happens when we pass 0 to strtoll() as base.

Diffstat:
includes/kore.h | 2+-
src/config.c | 6+++---
src/http.c | 4++--
src/utils.c | 14+++++++-------
4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/includes/kore.h b/includes/kore.h @@ -306,7 +306,7 @@ void kore_log(int, const char *, ...); void kore_strlcpy(char *, const char *, size_t); void kore_server_disconnect(struct connection *); int kore_split_string(char *, char *, char **, size_t); -long long kore_strtonum(const char *, long long, long long, int *); +long long kore_strtonum(const char *, int, long long, long long, int *); int kore_base64_encode(u_int8_t *, u_int32_t, char **); int kore_base64_decode(char *, u_int8_t **, u_int32_t *); diff --git a/src/config.c b/src/config.c @@ -221,7 +221,7 @@ configure_spdy_idle_time(char **argv) if (argv[1] == NULL) return (KORE_RESULT_ERROR); - spdy_idle_time = kore_strtonum(argv[1], 0, 65535, &err); + spdy_idle_time = kore_strtonum(argv[1], 10, 0, 65535, &err); if (err != KORE_RESULT_OK) { kore_debug("spdy_idle_time has invalid value: %s", argv[1]); return (KORE_RESULT_ERROR); @@ -328,7 +328,7 @@ configure_workers(char **argv) if (argv[1] == NULL) return (KORE_RESULT_ERROR); - worker_count = kore_strtonum(argv[1], 1, 255, &err); + worker_count = kore_strtonum(argv[1], 10, 1, 255, &err); if (err != KORE_RESULT_OK) { kore_debug("%s is not a correct worker number", argv[1]); return (KORE_RESULT_ERROR); @@ -427,7 +427,7 @@ configure_max_connections(char **argv) if (argv[1] == NULL) return (KORE_RESULT_ERROR); - worker_max_connections = kore_strtonum(argv[1], 1, 65535, &err); + worker_max_connections = kore_strtonum(argv[1], 10, 1, 65535, &err); if (err != KORE_RESULT_OK) return (KORE_RESULT_ERROR); diff --git a/src/http.c b/src/http.c @@ -403,7 +403,7 @@ http_header_recv(struct netbuf *nb) return (KORE_RESULT_ERROR); } - clen = kore_strtonum(p, 0, UINT_MAX, &v); + clen = kore_strtonum(p, 10, 0, UINT_MAX, &v); if (v == KORE_RESULT_ERROR) { kore_mem_free(p); kore_debug("content-length invalid: %s", p); @@ -523,7 +523,7 @@ http_argument_urldecode(char *arg) h[3] = *(p + 2); h[4] = '\0'; - v = kore_strtonum(h, 32, 127, &err); + v = kore_strtonum(h, 16, 32, 127, &err); if (err != KORE_RESULT_OK) return (err); diff --git a/src/utils.c b/src/utils.c @@ -87,7 +87,7 @@ kore_strlcpy(char *dst, const char *src, size_t len) } long long -kore_strtonum(const char *str, long long min, long long max, int *err) +kore_strtonum(const char *str, int base, long long min, long long max, int *err) { long long l; char *ep; @@ -99,7 +99,7 @@ kore_strtonum(const char *str, long long min, long long max, int *err) l = 0; errno = 0; - l = strtoll(str, &ep, 0); + l = strtoll(str, &ep, base); if (errno != 0 || str == ep || *ep != '\0') { *err = KORE_RESULT_ERROR; return (0); @@ -157,7 +157,7 @@ kore_date_to_time(char *http_date) goto out; } - tm.tm_year = kore_strtonum(args[3], 2013, 2068, &err) - 1900; + tm.tm_year = kore_strtonum(args[3], 10, 2013, 2068, &err) - 1900; if (err == KORE_RESULT_ERROR || tm.tm_year < gtm->tm_year) { kore_debug("misformed year in http-date: '%s'", http_date); goto out; @@ -175,7 +175,7 @@ kore_date_to_time(char *http_date) goto out; } - tm.tm_mday = kore_strtonum(args[1], 1, 31, &err); + tm.tm_mday = kore_strtonum(args[1], 10, 1, 31, &err); if (err == KORE_RESULT_ERROR) { kore_debug("misformed mday in http-date: '%s'", http_date); goto out; @@ -186,19 +186,19 @@ kore_date_to_time(char *http_date) goto out; } - tm.tm_hour = kore_strtonum(tbuf[0], 1, 23, &err); + tm.tm_hour = kore_strtonum(tbuf[0], 10, 1, 23, &err); if (err == KORE_RESULT_ERROR) { kore_debug("misformed hour in http-date: '%s'", http_date); goto out; } - tm.tm_min = kore_strtonum(tbuf[1], 1, 59, &err); + tm.tm_min = kore_strtonum(tbuf[1], 10, 1, 59, &err); if (err == KORE_RESULT_ERROR) { kore_debug("misformed minutes in http-date: '%s'", http_date); goto out; } - tm.tm_sec = kore_strtonum(tbuf[2], 0, 60, &err); + tm.tm_sec = kore_strtonum(tbuf[2], 10, 0, 60, &err); if (err == KORE_RESULT_ERROR) { kore_debug("misformed seconds in http-date: '%s'", http_date); goto out;