- int off = 0;
-
- /* we know buffer will be smaller than o->size - i*/
- *content_buf = (char*) odr_malloc(o, o->size - i);
-
- while (1)
- {
- /* chunk length .. */
- int chunk_len = 0;
- for (; i < o->size-2; i++)
- if (isdigit(o->buf[i]))
- chunk_len = chunk_len * 16 +
- (o->buf[i] - '0');
- else if (isupper(o->buf[i]))
- chunk_len = chunk_len * 16 +
- (o->buf[i] - ('A'-10));
- else if (islower(o->buf[i]))
- chunk_len = chunk_len * 16 +
- (o->buf[i] - ('a'-10));
- else
- break;
- /* chunk extension ... */
- while (o->buf[i] != '\r' && o->buf[i+1] != '\n')
- {
- if (i >= o->size-2)
- {
- o->error = OHTTP;
- return 0;
- }
- i++;
- }
- i += 2; /* skip CRLF */
- if (chunk_len == 0)
- break;
- if (chunk_len < 0 || off + chunk_len > o->size)
- {
- o->error = OHTTP;
- return 0;
- }
- /* copy chunk .. */
- memcpy (*content_buf + off, o->buf + i, chunk_len);
- i += chunk_len + 2; /* skip chunk+CRLF */
- off += chunk_len;
- }
- if (!off)
- *content_buf = 0;
- *content_len = off;
+ int off = 0;
+
+ /* we know buffer will be smaller than o->size - i*/
+ *content_buf = (char*) odr_malloc(o, o->size - i);
+
+ while (1)
+ {
+ /* chunk length .. */
+ int chunk_len = 0;
+ for (; i < o->size-2; i++)
+ if (isdigit(o->buf[i]))
+ chunk_len = chunk_len * 16 +
+ (o->buf[i] - '0');
+ else if (isupper(o->buf[i]))
+ chunk_len = chunk_len * 16 +
+ (o->buf[i] - ('A'-10));
+ else if (islower(o->buf[i]))
+ chunk_len = chunk_len * 16 +
+ (o->buf[i] - ('a'-10));
+ else
+ break;
+ /* chunk extension ... */
+ while (o->buf[i] != '\r' && o->buf[i+1] != '\n')
+ {
+ if (i >= o->size-2)
+ {
+ o->error = OHTTP;
+ return 0;
+ }
+ i++;
+ }
+ i += 2; /* skip CRLF */
+ if (chunk_len == 0)
+ break;
+ if (chunk_len < 0 || off + chunk_len > o->size)
+ {
+ o->error = OHTTP;
+ return 0;
+ }
+ /* copy chunk .. */
+ memcpy (*content_buf + off, o->buf + i, chunk_len);
+ i += chunk_len + 2; /* skip chunk+CRLF */
+ off += chunk_len;
+ }
+ if (!off)
+ *content_buf = 0;
+ *content_len = off;