- /* read in chunk size */
- while (isxdigit(*e_ptr)) {
- if (i == 9) {
- http_error_ex(E_WARNING, HTTP_E_PARSE, "Chunk size is too long: 0x%s...", hex_len);
+ chunk_len = strtol(e_ptr, &n_ptr, 16);
+
+ /* check if:
+ * - we could not read in chunk size
+ * - chunk size is not followed by HTTP_CRLF|NUL
+ */
+ if ((n_ptr == e_ptr) || (*n_ptr && (no_crlf = strncmp(n_ptr, HTTP_CRLF, lenof(HTTP_CRLF))))) {
+ /* don't fail on apperently not encoded data */
+ if (e_ptr == encoded) {
+ memcpy(*decoded, encoded, encoded_len);
+ *decoded_len = encoded_len;
+ return encoded + encoded_len;
+ } else {