You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2026/09/24 14:47:58 UTC

svn commit: r1938487 - in httpd/httpd/trunk: changes-entries modules/filters

Author: jorton
Date: Thu Sep 24 14:47:58 2026
New Revision: 1938487

Log:
* modules/filters/sed1.c (command): Take the octal digits the LCOM
  case writes off the unsigned byte value, not off a sign-extended
  char.

* changes-entries/sed-l-command.txt: Add.

Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
GitHub: PR #769

Added:
   httpd/httpd/trunk/changes-entries/sed-l-command.txt
Modified:
   httpd/httpd/trunk/modules/filters/sed1.c

Added: httpd/httpd/trunk/changes-entries/sed-l-command.txt
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ httpd/httpd/trunk/changes-entries/sed-l-command.txt	Thu Sep 24 14:47:58 2026	(r1938487)
@@ -0,0 +1,3 @@
+  *) mod_sed: Fix the octal escapes the "l" command writes for bytes with
+     the high bit set, which came out as nonsense such as "\/77" for 0xff.
+     [Joe Orton]

Modified: httpd/httpd/trunk/modules/filters/sed1.c
==============================================================================
--- httpd/httpd/trunk/modules/filters/sed1.c	Thu Sep 24 14:47:38 2026	(r1938486)
+++ httpd/httpd/trunk/modules/filters/sed1.c	Thu Sep 24 14:47:58 2026	(r1938487)
@@ -879,6 +879,13 @@ static apr_status_t command(sed_eval_t *
                         continue;
                     }
                     if (!isprint(*p1 & 0377)) {
+                        /* The three octal digits have to come off the byte
+                         * value, not off a sign-extended char: 0xff is
+                         * \377, and shifting it as a negative number gave
+                         * "\/77".
+                         */
+                        unsigned char uc = (unsigned char)*p1;
+
                         *p2++ = '\\';
                         if (p2 >= eval->lcomend) {
                             *p2 = '\\';
@@ -888,7 +895,7 @@ static apr_status_t command(sed_eval_t *
                                 return rv;
                             p2 = eval->genbuf;
                         }
-                        *p2++ = (*p1 >> 6) + '0';
+                        *p2++ = (uc >> 6) + '0';
                         if (p2 >= eval->lcomend) {
                             *p2 = '\\';
                             rv = wline(eval, eval->genbuf,
@@ -897,7 +904,7 @@ static apr_status_t command(sed_eval_t *
                                 return rv;
                             p2 = eval->genbuf;
                         }
-                        *p2++ = ((*p1 >> 3) & 07) + '0';
+                        *p2++ = ((uc >> 3) & 07) + '0';
                         if (p2 >= eval->lcomend) {
                             *p2 = '\\';
                             rv = wline(eval, eval->genbuf,
@@ -906,7 +913,8 @@ static apr_status_t command(sed_eval_t *
                                 return rv;
                             p2 = eval->genbuf;
                         }
-                        *p2++ = (*p1++ & 07) + '0';
+                        *p2++ = (uc & 07) + '0';
+                        p1++;
                         if (p2 >= eval->lcomend) {
                             *p2 = '\\';
                             rv = wline(eval, eval->genbuf,