From 13b20715bfff3981b9cf8e03658b9a68e7cae776 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Tue, 14 Nov 2023 20:34:01 +0100 Subject: [PATCH] fix(http_loop): correctly parse content-type --- src/http_loop/http_loop_steps.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/http_loop/http_loop_steps.c b/src/http_loop/http_loop_steps.c index c3ff36a..99c5cce 100644 --- a/src/http_loop/http_loop_steps.c +++ b/src/http_loop/http_loop_steps.c @@ -4,6 +4,18 @@ #include "http_loop.h" #include "lander.h" +// Just a naive pow implementation; might improve later +static uint64_t ipow(uint64_t base, uint64_t power) { + uint64_t res = 1; + + while (power > 0) { + res *= base; + power--; + } + + return res; +} + /* * Converts a string to a number, returning true if the string contained a valid * positive number. @@ -18,7 +30,7 @@ static bool string_to_num(size_t *res, const char *s, size_t len) { return false; } - *res += val * (int)pow(10, (len - 1) - i); + *res += (uint64_t)val * ipow(10, (len - 1) - i); } return true;