]> granicus.if.org Git - apache/commitdiff
* Saveguard ourselves against underflows
authorRuediger Pluem <rpluem@apache.org>
Tue, 8 Jan 2008 19:50:01 +0000 (19:50 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 8 Jan 2008 19:50:01 +0000 (19:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@610111 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_filters.c

index dbc39fdab9312e93b6fbafc5985c5e4c7b533323..a5ff3ae8f1e3608348bdaa5be9f3f4710683ad28 100644 (file)
@@ -159,9 +159,17 @@ static apr_status_t get_chunk_line(http_ctx_t *ctx, apr_bucket_brigade *b,
                                    int linelimit)
 {
     apr_size_t len;
+    int tmp_len;
     apr_status_t rv;
 
-    len = sizeof(ctx->chunk_ln) - (ctx->pos - ctx->chunk_ln) - 1;
+    tmp_len = sizeof(ctx->chunk_ln) - (ctx->pos - ctx->chunk_ln) - 1;
+    /* Saveguard ourselves against underflows */
+    if (tmp_len < 0) {
+        len = 0;
+    }
+    else {
+        len = (apr_size_t) tmp_len;
+    }
     /*
      * Check if there is space left in ctx->chunk_ln. If not, then either
      * the chunk size is insane or we have chunk-extensions. Ignore both