Check if the return buffer is biggest enough.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 3 Oct 2011 15:04:52 +0000 (15:04 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 3 Oct 2011 15:04:52 +0000 (15:04 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5135 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/net/http.c

index 891c462bbd13356c0920d0803e38c070e43c9785..dd4ee4fd22ffdcdda57f3efba7174f47b39c06d5 100644 (file)
@@ -83,6 +83,9 @@ void http_decodeUri(const char *raw_buf, size_t raw_len, char *decodec_buf, size
        char value;
        for (size_t i = 0; i < raw_len; i++)
        {
+               if (!len)
+                       return;
+
                if (raw_buf[i] == '%')
                {
                        if (i + 2 < raw_len)
@@ -92,12 +95,14 @@ void http_decodeUri(const char *raw_buf, size_t raw_len, char *decodec_buf, size
                                if (value)
                                {
                                        *decodec_buf++ = value;
+                                       len--;
                                        i += 2;
                                        continue;
                                }
                        }
                }
                *decodec_buf++ = raw_buf[i];
+               len--;
        }
 }