Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi/dist/common search.c: correctly handle esca...



details:   https://anonhg.NetBSD.org/src/rev/c5e74185f928
branches:  trunk
changeset: 373504:c5e74185f928
user:      gutteridge <gutteridge%NetBSD.org@localhost>
date:      Mon Feb 13 23:08:43 2023 +0000

description:
search.c: correctly handle escaped backslashes

Addresses PR bin/57106 from Bosco G. G., who supplied the patch.
(This was also committed in the nvi2 sources:
https://github.com/lichray/nvi2/commit/e7054267a371d5caa81edb218f5c8388e11b5197)

diffstat:

 external/bsd/nvi/dist/common/search.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r b0176d9d02a7 -r c5e74185f928 external/bsd/nvi/dist/common/search.c
--- a/external/bsd/nvi/dist/common/search.c     Mon Feb 13 23:02:27 2023 +0000
+++ b/external/bsd/nvi/dist/common/search.c     Mon Feb 13 23:08:43 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $ */
+/*     $NetBSD: search.c,v 1.5 2023/02/13 23:08:43 gutteridge Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: search.c,v 10.31 2001/06/25 15:19:12 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:12 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: search.c,v 1.4 2017/11/22 16:17:30 rin Exp $");
+__RCSID("$NetBSD: search.c,v 1.5 2023/02/13 23:08:43 gutteridge Exp $");
 #endif
 
 #include <sys/types.h>
@@ -110,9 +110,14 @@
                                        ++p;
                                break;
                        }
-                       if (plen > 1 && p[0] == '\\' && p[1] == delim) {
-                               ++p;
-                               --plen;
+                       if (plen > 1 && p[0] == '\\') {
+                               if(p[1] == delim) {
+                                       ++p;
+                                       --plen;
+                               } else if(p[1] == '\\') {
+                                       *t++ = *p++;
+                                       --plen;
+                               }
                        }
                }
                if (epp != NULL)



Home | Main Index | Thread Index | Old Index