aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-07-28 15:15:47 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-07-28 15:15:47 +0000
commit1b4c2ffe98945fbdffddc7f1ffaa5c166848cc58 (patch)
tree0b518e8c5952f391d7b3a241084e1109c01b8ae7
parent4d0d4701c6d3a5aa8f6075aa48b1d227c24847cd (diff)
downloadlibmicrohttpd-1b4c2ffe98945fbdffddc7f1ffaa5c166848cc58.tar.gz
libmicrohttpd-1b4c2ffe98945fbdffddc7f1ffaa5c166848cc58.zip
MHD_http_unescape(): replace call of strtoul() with MHD_strx_to_uint32_n_()
-rw-r--r--src/microhttpd/internal.c16
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 @@
25 */ 25 */
26 26
27#include "internal.h" 27#include "internal.h"
28#include "mhd_str.h"
28 29
29#ifdef HAVE_MESSAGES 30#ifdef HAVE_MESSAGES
30#if DEBUG_STATES 31#if DEBUG_STATES
@@ -134,31 +135,22 @@ MHD_http_unescape (char *val)
134 char *rpos = val; 135 char *rpos = val;
135 char *wpos = val; 136 char *wpos = val;
136 char *end; 137 char *end;
137 unsigned int num;
138 char buf3[3]; 138 char buf3[3];
139 139
140 while ('\0' != *rpos) 140 while ('\0' != *rpos)
141 { 141 {
142 uint32_t num;
142 switch (*rpos) 143 switch (*rpos)
143 { 144 {
144 case '%': 145 case '%':
145 if ( ('\0' == rpos[1]) || 146 if (2 == MHD_strx_to_uint32_n_ (rpos + 1, 2, &num))
146 ('\0' == rpos[2]) )
147 {
148 *wpos = '\0';
149 return wpos - val;
150 }
151 buf3[0] = rpos[1];
152 buf3[1] = rpos[2];
153 buf3[2] = '\0';
154 num = strtoul (buf3, &end, 16);
155 if ('\0' == *end)
156 { 147 {
157 *wpos = (char)((unsigned char) num); 148 *wpos = (char)((unsigned char) num);
158 wpos++; 149 wpos++;
159 rpos += 3; 150 rpos += 3;
160 break; 151 break;
161 } 152 }
153 /* TODO: add bad sequence handling */
162 /* intentional fall through! */ 154 /* intentional fall through! */
163 default: 155 default:
164 *wpos = *rpos; 156 *wpos = *rpos;