diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-07-28 15:15:47 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-07-28 15:15:47 +0000 |
commit | 1b4c2ffe98945fbdffddc7f1ffaa5c166848cc58 (patch) | |
tree | 0b518e8c5952f391d7b3a241084e1109c01b8ae7 | |
parent | 4d0d4701c6d3a5aa8f6075aa48b1d227c24847cd (diff) |
MHD_http_unescape(): replace call of strtoul() with MHD_strx_to_uint32_n_()
-rw-r--r-- | src/microhttpd/internal.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c index 547fd5a0..035a1551 100644 --- a/src/microhttpd/internal.c +++ b/src/microhttpd/internal.c @@ -25,6 +25,7 @@ */ #include "internal.h" +#include "mhd_str.h" #ifdef HAVE_MESSAGES #if DEBUG_STATES @@ -134,31 +135,22 @@ MHD_http_unescape (char *val) char *rpos = val; char *wpos = val; char *end; - unsigned int num; char buf3[3]; while ('\0' != *rpos) { + uint32_t num; switch (*rpos) { case '%': - if ( ('\0' == rpos[1]) || - ('\0' == rpos[2]) ) - { - *wpos = '\0'; - return wpos - val; - } - buf3[0] = rpos[1]; - buf3[1] = rpos[2]; - buf3[2] = '\0'; - num = strtoul (buf3, &end, 16); - if ('\0' == *end) + if (2 == MHD_strx_to_uint32_n_ (rpos + 1, 2, &num)) { *wpos = (char)((unsigned char) num); wpos++; rpos += 3; break; } + /* TODO: add bad sequence handling */ /* intentional fall through! */ default: *wpos = *rpos; |