SHA256
1
0
forked from pool/sed
sed/sed-y-NUL-RHS.patch
Stanislav Brabec aab5852676 Accepting request 326633 from home:sbrabec:branches:Base:System
- Cherry picking of the most important fixes from the upstream sed
  GIT (not backporting testsuite, as it was completely refactored):
  * Fix y command in the RHS of a y/LHS/RHS/ transliteration
    (sed-y-NUL-RHS.patch).
  * Fix mishandling of overlapping address ranges
    (sed-fix-overlapping-address-ranges.patch).
  * Fix fail to remove a temporary file (sed-temp-delete.patch).
  * Fix behavior of --follow-symlinks when reading from stdin
    (bnc#933029, gnu#20795, sed-follow-symlinks-stdin.patch).
  * Make "sed --follow-symlinks -" consistent with "sed -" again,
    and process stdin instead of ./-
    (bnc#933029#c6, gnu#20796, sed-follow-symlinks-hyphen.patch).

OBS-URL: https://build.opensuse.org/request/show/326633
OBS-URL: https://build.opensuse.org/package/show/Base:System/sed?expand=0&rev=22
2015-08-27 16:10:55 +00:00

46 lines
1.8 KiB
Diff

This is a backport of the fix itself.
From 643f692bc7b02086e91c2afd12bf9ac8b40b6fe4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Thu, 4 Sep 2014 20:52:12 -0700
Subject: [PATCH 12/92] fix "y" to work with NUL in the RHS
* sed/execute.c (do_list) [case 'y']: Handle NUL bytes
in the RHS of a y/LHS/RHS/ transliteration.
* testsuite/y-zero.good: New test-related files.
* testsuite/y-zero.inp:
* testsuite/y-zero.sed:
* testsuite/Makefile.am (SEDTESTS): Add y-zero here.
* testsuite/Makefile.tests: And here.
* NEWS (Bug fixes): Describe it.
The bug was reported by table@inventati.org,
with the execute.c change mostly by Paolo Bonzini.
---
ChangeLog | 14 ++++++++++++++
NEWS | 18 +++++++++++++++++-
sed/execute.c | 3 ++-
testsuite/Makefile.am | 3 ++-
testsuite/Makefile.tests | 2 +-
testsuite/y-zero.good | Bin 0 -> 4 bytes
testsuite/y-zero.inp | 1 +
testsuite/y-zero.sed | 1 +
8 files changed, 38 insertions(+), 4 deletions(-)
create mode 100644 testsuite/y-zero.good
create mode 100644 testsuite/y-zero.inp
create mode 100644 testsuite/y-zero.sed
Index: sed-4.2.2/sed/execute.c
===================================================================
--- sed-4.2.2.orig/sed/execute.c
+++ sed-4.2.2/sed/execute.c
@@ -1572,7 +1572,8 @@ execute_program(vec, input)
if (strncmp(line.active + idx, trans[2*i], mbclen) == 0)
{
bool move_remain_buffer = false;
- int trans_len = strlen(trans[2*i+1]);
+ const char *tr = trans[2*i+1];
+ size_t trans_len = *tr == '\0' ? 1 : strlen (tr);
if (mbclen < trans_len)
{