Blame SOURCES/httpd-2.4.34-CVE-2022-30522.patch

879b17
diff --git a/modules/filters/mod_sed.c b/modules/filters/mod_sed.c
879b17
index 8595e41..9b99a6b 100644
879b17
--- a/modules/filters/mod_sed.c
879b17
+++ b/modules/filters/mod_sed.c
879b17
@@ -59,7 +59,7 @@ typedef struct sed_filter_ctxt
879b17
 module AP_MODULE_DECLARE_DATA sed_module;
879b17
 
879b17
 /* This function will be call back from libsed functions if there is any error
879b17
- * happend during execution of sed scripts
879b17
+ * happened during execution of sed scripts
879b17
  */
879b17
 static apr_status_t log_sed_errf(void *data, const char *error)
879b17
 {
879b17
@@ -276,7 +276,7 @@ static apr_status_t sed_response_filter(ap_filter_t *f,
879b17
                                         apr_bucket_brigade *bb)
879b17
 {
879b17
     apr_bucket *b;
879b17
-    apr_status_t status;
879b17
+    apr_status_t status = APR_SUCCESS;
879b17
     sed_config *cfg = ap_get_module_config(f->r->per_dir_config,
879b17
                                            &sed_module);
879b17
     sed_filter_ctxt *ctx = f->ctx;
879b17
@@ -301,9 +301,9 @@ static apr_status_t sed_response_filter(ap_filter_t *f,
879b17
              return status;
879b17
         ctx = f->ctx;
879b17
         apr_table_unset(f->r->headers_out, "Content-Length");
879b17
-    }
879b17
 
879b17
-    ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
879b17
+        ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
879b17
+    }
879b17
 
879b17
     /* Here is the main logic. Iterate through all the buckets, read the
879b17
      * content of the bucket, call sed_eval_buffer on the data.
879b17
@@ -325,63 +325,52 @@ static apr_status_t sed_response_filter(ap_filter_t *f,
879b17
      * in sed's internal buffer which can't be flushed until new line
879b17
      * character is arrived.
879b17
      */
879b17
-    for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb);) {
879b17
-        const char *buf = NULL;
879b17
-        apr_size_t bytes = 0;
879b17
+    while (!APR_BRIGADE_EMPTY(bb)) {
879b17
+        b = APR_BRIGADE_FIRST(bb);
879b17
         if (APR_BUCKET_IS_EOS(b)) {
879b17
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
879b17
             /* Now clean up the internal sed buffer */
879b17
             sed_finalize_eval(&ctx->eval, ctx);
879b17
             status = flush_output_buffer(ctx);
879b17
             if (status != APR_SUCCESS) {
879b17
-                clear_ctxpool(ctx);
879b17
-                return status;
879b17
+                break;
879b17
             }
879b17
+            /* Move the eos bucket to ctx->bb brigade */
879b17
             APR_BUCKET_REMOVE(b);
879b17
-            /* Insert the eos bucket to ctx->bb brigade */
879b17
             APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
879b17
-            b = b1;
879b17
         }
879b17
         else if (APR_BUCKET_IS_FLUSH(b)) {
879b17
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
879b17
-            APR_BUCKET_REMOVE(b);
879b17
             status = flush_output_buffer(ctx);
879b17
             if (status != APR_SUCCESS) {
879b17
-                clear_ctxpool(ctx);
879b17
-                return status;
879b17
+                break;
879b17
             }
879b17
+            /* Move the flush bucket to ctx->bb brigade */
879b17
+            APR_BUCKET_REMOVE(b);
879b17
             APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
879b17
-            b = b1;
879b17
-        }
879b17
-        else if (APR_BUCKET_IS_METADATA(b)) {
879b17
-            b = APR_BUCKET_NEXT(b);
879b17
         }
879b17
-        else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ)
879b17
-                 == APR_SUCCESS) {
879b17
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
879b17
-            status = sed_eval_buffer(&ctx->eval, buf, bytes, ctx);
879b17
-            if (status != APR_SUCCESS) {
879b17
-                clear_ctxpool(ctx);
879b17
-                return status;
879b17
+        else {
879b17
+            if (!APR_BUCKET_IS_METADATA(b)) {
879b17
+                const char *buf = NULL;
879b17
+                apr_size_t bytes = 0;
879b17
+
879b17
+                status = apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ);
879b17
+                if (status == APR_SUCCESS) {
879b17
+                    status = sed_eval_buffer(&ctx->eval, buf, bytes, ctx);
879b17
+                }
879b17
+                if (status != APR_SUCCESS) {
879b17
+                    ap_log_rerror(APLOG_MARK, APLOG_ERR, status, f->r, APLOGNO(10394) "error evaluating sed on output");
879b17
+                    break;
879b17
+                }
879b17
             }
879b17
-            APR_BUCKET_REMOVE(b);
879b17
             apr_bucket_delete(b);
879b17
-            b = b1;
879b17
-        }
879b17
-        else {
879b17
-            apr_bucket *b1 = APR_BUCKET_NEXT(b);
879b17
-            APR_BUCKET_REMOVE(b);
879b17
-            b = b1;
879b17
         }
879b17
     }
879b17
-    apr_brigade_cleanup(bb);
879b17
-    status = flush_output_buffer(ctx);
879b17
-    if (status != APR_SUCCESS) {
879b17
-        clear_ctxpool(ctx);
879b17
-        return status;
879b17
+    if (status == APR_SUCCESS) {
879b17
+        status = flush_output_buffer(ctx);
879b17
     }
879b17
     if (!APR_BRIGADE_EMPTY(ctx->bb)) {
879b17
-        status = ap_pass_brigade(f->next, ctx->bb);
879b17
+        if (status == APR_SUCCESS) {
879b17
+            status = ap_pass_brigade(f->next, ctx->bb);
879b17
+        }
879b17
         apr_brigade_cleanup(ctx->bb);
879b17
     }
879b17
     clear_ctxpool(ctx);
879b17
@@ -432,7 +421,7 @@ static apr_status_t sed_request_filter(ap_filter_t *f,
879b17
      * the buckets in bbinp and read the data from buckets and invoke
879b17
      * sed_eval_buffer on the data. libsed will generate its output using
879b17
      * sed_write_output which will add data in ctx->bb. Do it until it have
879b17
-     * atleast one bucket in ctx->bb. At the end of data eos bucket
879b17
+     * at least one bucket in ctx->bb. At the end of data eos bucket
879b17
      * should be there.
879b17
      *
879b17
      * Once eos bucket is seen, then invoke sed_finalize_eval to clear the
879b17
@@ -474,8 +463,10 @@ static apr_status_t sed_request_filter(ap_filter_t *f,
879b17
             if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ)
879b17
                      == APR_SUCCESS) {
879b17
                 status = sed_eval_buffer(&ctx->eval, buf, bytes, ctx);
879b17
-                if (status != APR_SUCCESS)
879b17
+                if (status != APR_SUCCESS) { 
879b17
+                    ap_log_rerror(APLOG_MARK, APLOG_ERR, status, f->r, APLOGNO(10395) "error evaluating sed on input");
879b17
                     return status;
879b17
+                }
879b17
                 flush_output_buffer(ctx);
879b17
             }
879b17
         }
879b17
diff --git a/modules/filters/sed1.c b/modules/filters/sed1.c
879b17
index d88a547..ff17ef9 100644
879b17
--- a/modules/filters/sed1.c
879b17
+++ b/modules/filters/sed1.c
879b17
@@ -87,18 +87,20 @@ static void eval_errf(sed_eval_t *eval, const char *fmt, ...)
879b17
 }
879b17
 
879b17
 #define INIT_BUF_SIZE 1024
879b17
+#define MAX_BUF_SIZE 1024*8192
879b17
 
879b17
 /*
879b17
  * grow_buffer
879b17
  */
879b17
-static void grow_buffer(apr_pool_t *pool, char **buffer,
879b17
+static apr_status_t grow_buffer(apr_pool_t *pool, char **buffer,
879b17
                         char **spend, apr_size_t *cursize,
879b17
                         apr_size_t newsize)
879b17
 {
879b17
     char* newbuffer = NULL;
879b17
     apr_size_t spendsize = 0;
879b17
-    if (*cursize >= newsize)
879b17
-        return;
879b17
+    if (*cursize >= newsize) {
879b17
+        return APR_SUCCESS;
879b17
+    }
879b17
     /* Avoid number of times realloc is called. It could cause huge memory
879b17
      * requirement if line size is huge e.g 2 MB */
879b17
     if (newsize < *cursize * 2) {
879b17
@@ -107,6 +109,9 @@ static void grow_buffer(apr_pool_t *pool, char **buffer,
879b17
 
879b17
     /* Align it to 4 KB boundary */
879b17
     newsize = (newsize  + ((1 << 12) - 1)) & ~((1 << 12) -1);
879b17
+    if (newsize > MAX_BUF_SIZE) {
879b17
+        return APR_ENOMEM;
879b17
+    }
879b17
     newbuffer = apr_pcalloc(pool, newsize);
879b17
     if (*spend && *buffer && (*cursize > 0)) {
879b17
         spendsize = *spend - *buffer;
879b17
@@ -119,63 +124,77 @@ static void grow_buffer(apr_pool_t *pool, char **buffer,
879b17
     if (spend != buffer) {
879b17
         *spend = *buffer + spendsize;
879b17
     }
879b17
+    return APR_SUCCESS;
879b17
 }
879b17
 
879b17
 /*
879b17
  * grow_line_buffer
879b17
  */
879b17
-static void grow_line_buffer(sed_eval_t *eval, apr_size_t newsize)
879b17
+static apr_status_t grow_line_buffer(sed_eval_t *eval, apr_size_t newsize)
879b17
 {
879b17
-    grow_buffer(eval->pool, &eval->linebuf, &eval->lspend,
879b17
+    return grow_buffer(eval->pool, &eval->linebuf, &eval->lspend,
879b17
                 &eval->lsize, newsize);
879b17
 }
879b17
 
879b17
 /*
879b17
  * grow_hold_buffer
879b17
  */
879b17
-static void grow_hold_buffer(sed_eval_t *eval, apr_size_t newsize)
879b17
+static apr_status_t grow_hold_buffer(sed_eval_t *eval, apr_size_t newsize)
879b17
 {
879b17
-    grow_buffer(eval->pool, &eval->holdbuf, &eval->hspend,
879b17
+    return grow_buffer(eval->pool, &eval->holdbuf, &eval->hspend,
879b17
                 &eval->hsize, newsize);
879b17
 }
879b17
 
879b17
 /*
879b17
  * grow_gen_buffer
879b17
  */
879b17
-static void grow_gen_buffer(sed_eval_t *eval, apr_size_t newsize,
879b17
+static apr_status_t grow_gen_buffer(sed_eval_t *eval, apr_size_t newsize,
879b17
                             char **gspend)
879b17
 {
879b17
+    apr_status_t rc = 0;
879b17
     if (gspend == NULL) {
879b17
         gspend = &eval->genbuf;
879b17
     }
879b17
-    grow_buffer(eval->pool, &eval->genbuf, gspend,
879b17
-                &eval->gsize, newsize);
879b17
-    eval->lcomend = &eval->genbuf[71];
879b17
+    rc = grow_buffer(eval->pool, &eval->genbuf, gspend,
879b17
+                     &eval->gsize, newsize);
879b17
+    if (rc == APR_SUCCESS) { 
879b17
+        eval->lcomend = &eval->genbuf[71];
879b17
+    }
879b17
+    return rc;
879b17
 }
879b17
 
879b17
 /*
879b17
  * appendmem_to_linebuf
879b17
  */
879b17
-static void appendmem_to_linebuf(sed_eval_t *eval, const char* sz, apr_size_t len)
879b17
+static apr_status_t appendmem_to_linebuf(sed_eval_t *eval, const char* sz, apr_size_t len)
879b17
 {
879b17
+    apr_status_t rc = 0;
879b17
     apr_size_t reqsize = (eval->lspend - eval->linebuf) + len;
879b17
     if (eval->lsize < reqsize) {
879b17
-        grow_line_buffer(eval, reqsize);
879b17
+        rc = grow_line_buffer(eval, reqsize);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
     }
879b17
     memcpy(eval->lspend, sz, len);
879b17
     eval->lspend += len;
879b17
+    return APR_SUCCESS;
879b17
 }
879b17
 
879b17
 /*
879b17
  * append_to_linebuf
879b17
  */
879b17
-static void append_to_linebuf(sed_eval_t *eval, const char* sz,
879b17
+static apr_status_t append_to_linebuf(sed_eval_t *eval, const char* sz,
879b17
                               step_vars_storage *step_vars)
879b17
 {
879b17
     apr_size_t len = strlen(sz);
879b17
     char *old_linebuf = eval->linebuf;
879b17
+    apr_status_t rc = 0;
879b17
     /* Copy string including null character */
879b17
-    appendmem_to_linebuf(eval, sz, len + 1);
879b17
+    rc = appendmem_to_linebuf(eval, sz, len + 1);
879b17
+    if (rc != APR_SUCCESS) { 
879b17
+        return rc;
879b17
+    }
879b17
     --eval->lspend; /* lspend will now point to NULL character */
879b17
     /* Sync step_vars after a possible linebuf expansion */
879b17
     if (step_vars && old_linebuf != eval->linebuf) {
879b17
@@ -189,68 +208,84 @@ static void append_to_linebuf(sed_eval_t *eval, const char* sz,
879b17
             step_vars->locs = step_vars->locs - old_linebuf + eval->linebuf;
879b17
         }
879b17
     }
879b17
+    return APR_SUCCESS;
879b17
 }
879b17
 
879b17
 /*
879b17
  * copy_to_linebuf
879b17
  */
879b17
-static void copy_to_linebuf(sed_eval_t *eval, const char* sz,
879b17
+static apr_status_t copy_to_linebuf(sed_eval_t *eval, const char* sz,
879b17
                             step_vars_storage *step_vars)
879b17
 {
879b17
     eval->lspend = eval->linebuf;
879b17
-    append_to_linebuf(eval, sz, step_vars);
879b17
+    return append_to_linebuf(eval, sz, step_vars);
879b17
 }
879b17
 
879b17
 /*
879b17
  * append_to_holdbuf
879b17
  */
879b17
-static void append_to_holdbuf(sed_eval_t *eval, const char* sz)
879b17
+static apr_status_t append_to_holdbuf(sed_eval_t *eval, const char* sz)
879b17
 {
879b17
     apr_size_t len = strlen(sz);
879b17
     apr_size_t reqsize = (eval->hspend - eval->holdbuf) + len + 1;
879b17
+    apr_status_t rc = 0;
879b17
     if (eval->hsize <= reqsize) {
879b17
-        grow_hold_buffer(eval, reqsize);
879b17
+        rc = grow_hold_buffer(eval, reqsize);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
     }
879b17
     memcpy(eval->hspend, sz, len + 1);
879b17
     /* hspend will now point to NULL character */
879b17
     eval->hspend += len;
879b17
+    return APR_SUCCESS;
879b17
 }
879b17
 
879b17
 /*
879b17
  * copy_to_holdbuf
879b17
  */
879b17
-static void copy_to_holdbuf(sed_eval_t *eval, const char* sz)
879b17
+static apr_status_t copy_to_holdbuf(sed_eval_t *eval, const char* sz)
879b17
 {
879b17
     eval->hspend = eval->holdbuf;
879b17
-    append_to_holdbuf(eval, sz);
879b17
+    return append_to_holdbuf(eval, sz);
879b17
 }
879b17
 
879b17
 /*
879b17
  * append_to_genbuf
879b17
  */
879b17
-static void append_to_genbuf(sed_eval_t *eval, const char* sz, char **gspend)
879b17
+static apr_status_t append_to_genbuf(sed_eval_t *eval, const char* sz, char **gspend)
879b17
 {
879b17
     apr_size_t len = strlen(sz);
879b17
     apr_size_t reqsize = (*gspend - eval->genbuf) + len + 1;
879b17
+    apr_status_t rc = 0;
879b17
     if (eval->gsize < reqsize) {
879b17
-        grow_gen_buffer(eval, reqsize, gspend);
879b17
+        rc = grow_gen_buffer(eval, reqsize, gspend);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
     }
879b17
     memcpy(*gspend, sz, len + 1);
879b17
     /* *gspend will now point to NULL character */
879b17
     *gspend += len;
879b17
+    return APR_SUCCESS;
879b17
 }
879b17
 
879b17
 /*
879b17
  * copy_to_genbuf
879b17
  */
879b17
-static void copy_to_genbuf(sed_eval_t *eval, const char* sz)
879b17
+static apr_status_t copy_to_genbuf(sed_eval_t *eval, const char* sz)
879b17
 {
879b17
     apr_size_t len = strlen(sz);
879b17
     apr_size_t reqsize = len + 1;
879b17
+    apr_status_t rc = APR_SUCCESS;;
879b17
     if (eval->gsize < reqsize) {
879b17
-        grow_gen_buffer(eval, reqsize, NULL);
879b17
+        rc = grow_gen_buffer(eval, reqsize, NULL);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
     }
879b17
     memcpy(eval->genbuf, sz, len + 1);
879b17
+    return rc;
879b17
 }
879b17
 
879b17
 /*
879b17
@@ -397,6 +432,7 @@ apr_status_t sed_eval_buffer(sed_eval_t *eval, const char *buf, apr_size_t bufsz
879b17
     }
879b17
 
879b17
     while (bufsz) {
879b17
+        apr_status_t rc = 0;
879b17
         char *n;
879b17
         apr_size_t llen;
879b17
 
879b17
@@ -411,7 +447,10 @@ apr_status_t sed_eval_buffer(sed_eval_t *eval, const char *buf, apr_size_t bufsz
879b17
             break;
879b17
         }
879b17
 
879b17
-        appendmem_to_linebuf(eval, buf, llen + 1);
879b17
+        rc = appendmem_to_linebuf(eval, buf, llen + 1);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
         --eval->lspend;
879b17
         /* replace new line character with NULL */
879b17
         *eval->lspend = '\0';
879b17
@@ -426,7 +465,10 @@ apr_status_t sed_eval_buffer(sed_eval_t *eval, const char *buf, apr_size_t bufsz
879b17
 
879b17
     /* Save the leftovers for later */
879b17
     if (bufsz) {
879b17
-        appendmem_to_linebuf(eval, buf, bufsz);
879b17
+        apr_status_t rc = appendmem_to_linebuf(eval, buf, bufsz);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return rc;
879b17
+        }
879b17
     }
879b17
 
879b17
     return APR_SUCCESS;
879b17
@@ -448,6 +490,7 @@ apr_status_t sed_finalize_eval(sed_eval_t *eval, void *fout)
879b17
     /* Process leftovers */
879b17
     if (eval->lspend > eval->linebuf) {
879b17
         apr_status_t rv;
879b17
+        apr_status_t rc = 0;
879b17
 
879b17
         if (eval->lreadyflag) {
879b17
             eval->lreadyflag = 0;
879b17
@@ -457,7 +500,10 @@ apr_status_t sed_finalize_eval(sed_eval_t *eval, void *fout)
879b17
              * buffer is not a newline.
879b17
              */
879b17
             /* Assure space for NULL */
879b17
-            append_to_linebuf(eval, "", NULL);
879b17
+            rc = append_to_linebuf(eval, "", NULL);
879b17
+            if (rc != APR_SUCCESS) { 
879b17
+                return rc;
879b17
+            }
879b17
         }
879b17
 
879b17
         *eval->lspend = '\0';
879b17
@@ -655,11 +701,15 @@ static apr_status_t dosub(sed_eval_t *eval, char *rhsbuf, int n,
879b17
     sp = eval->genbuf;
879b17
     rp = rhsbuf;
879b17
     sp = place(eval, sp, lp, step_vars->loc1);
879b17
+    if (sp == NULL) { 
879b17
+        return APR_EGENERAL;
879b17
+    }
879b17
     while ((c = *rp++) != 0) {
879b17
         if (c == '&') {
879b17
             sp = place(eval, sp, step_vars->loc1, step_vars->loc2);
879b17
-            if (sp == NULL)
879b17
+            if (sp == NULL) {
879b17
                 return APR_EGENERAL;
879b17
+            }
879b17
         }
879b17
         else if (c == '\\') {
879b17
             c = *rp++;
879b17
@@ -675,13 +725,19 @@ static apr_status_t dosub(sed_eval_t *eval, char *rhsbuf, int n,
879b17
             *sp++ = c;
879b17
         if (sp >= eval->genbuf + eval->gsize) {
879b17
             /* expand genbuf and set the sp appropriately */
879b17
-            grow_gen_buffer(eval, eval->gsize + 1024, &sp);
879b17
+            rv = grow_gen_buffer(eval, eval->gsize + 1024, &sp);
879b17
+            if (rv != APR_SUCCESS) { 
879b17
+                return rv;
879b17
+            }
879b17
         }
879b17
     }
879b17
     lp = step_vars->loc2;
879b17
     step_vars->loc2 = sp - eval->genbuf + eval->linebuf;
879b17
-    append_to_genbuf(eval, lp, &sp);
879b17
-    copy_to_linebuf(eval, eval->genbuf, step_vars);
879b17
+    rv = append_to_genbuf(eval, lp, &sp);
879b17
+    if (rv != APR_SUCCESS) { 
879b17
+        return rv;
879b17
+    }
879b17
+    rv = copy_to_linebuf(eval, eval->genbuf, step_vars);
879b17
     return rv;
879b17
 }
879b17
 
879b17
@@ -695,7 +751,10 @@ static char *place(sed_eval_t *eval, char *asp, char *al1, char *al2)
879b17
     apr_size_t reqsize = (sp - eval->genbuf) + n + 1;
879b17
 
879b17
     if (eval->gsize < reqsize) {
879b17
-        grow_gen_buffer(eval, reqsize, &sp);
879b17
+        apr_status_t rc = grow_gen_buffer(eval, reqsize, &sp);
879b17
+        if (rc != APR_SUCCESS) { 
879b17
+            return NULL;
879b17
+        }
879b17
     }
879b17
     memcpy(sp, al1, n);
879b17
     return sp + n;
879b17
@@ -748,7 +807,8 @@ static apr_status_t command(sed_eval_t *eval, sed_reptr_t *ipc,
879b17
             }
879b17
 
879b17
             p1++;
879b17
-            copy_to_linebuf(eval, p1, step_vars);
879b17
+            rv = copy_to_linebuf(eval, p1, step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             eval->jflag++;
879b17
             break;
879b17
 
879b17
@@ -758,21 +818,27 @@ static apr_status_t command(sed_eval_t *eval, sed_reptr_t *ipc,
879b17
             break;
879b17
 
879b17
         case GCOM:
879b17
-            copy_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
+            rv = copy_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             break;
879b17
 
879b17
         case CGCOM:
879b17
-            append_to_linebuf(eval, "\n", step_vars);
879b17
-            append_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
+            rv = append_to_linebuf(eval, "\n", step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
+            rv = append_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             break;
879b17
 
879b17
         case HCOM:
879b17
-            copy_to_holdbuf(eval, eval->linebuf);
879b17
+            rv = copy_to_holdbuf(eval, eval->linebuf);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             break;
879b17
 
879b17
         case CHCOM:
879b17
-            append_to_holdbuf(eval, "\n");
879b17
-            append_to_holdbuf(eval, eval->linebuf);
879b17
+            rv = append_to_holdbuf(eval, "\n");
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
+            rv = append_to_holdbuf(eval, eval->linebuf);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             break;
879b17
 
879b17
         case ICOM:
879b17
@@ -894,7 +960,8 @@ static apr_status_t command(sed_eval_t *eval, sed_reptr_t *ipc,
879b17
                 if (rv != APR_SUCCESS)
879b17
                     return rv;
879b17
             }
879b17
-            append_to_linebuf(eval, "\n", step_vars);
879b17
+            rv = append_to_linebuf(eval, "\n", step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             eval->pending = ipc->next;
879b17
             break;
879b17
 
879b17
@@ -965,9 +1032,12 @@ static apr_status_t command(sed_eval_t *eval, sed_reptr_t *ipc,
879b17
                                 eval->linebuf);
879b17
             break;
879b17
         case XCOM:
879b17
-            copy_to_genbuf(eval, eval->linebuf);
879b17
-            copy_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
-            copy_to_holdbuf(eval, eval->genbuf);
879b17
+            rv = copy_to_genbuf(eval, eval->linebuf);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
+            rv = copy_to_linebuf(eval, eval->holdbuf, step_vars);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
+            rv = copy_to_holdbuf(eval, eval->genbuf);
879b17
+            if (rv != APR_SUCCESS) return rv;
879b17
             break;
879b17
 
879b17
         case YCOM: