Module Name:    src
Committed By:   christos
Date:           Sun Jun 30 16:26:30 UTC 2024

Modified Files:
        src/lib/libedit: search.c

Log Message:
Prevent reading before the line buffer (try ^R^W in emacs mode at the
beginning of the line) (Robert Morris)
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279426


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libedit/search.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libedit/search.c
diff -u src/lib/libedit/search.c:1.51 src/lib/libedit/search.c:1.52
--- src/lib/libedit/search.c:1.51	Mon Mar 30 02:56:38 2020
+++ src/lib/libedit/search.c	Sun Jun 30 12:26:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $	*/
+/*	$NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)search.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: search.c,v 1.51 2020/03/30 06:56:38 ryo Exp $");
+__RCSID("$NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -295,6 +295,9 @@ ce_inc_search(EditLine *el, int dir)
 				for (cp = &el->el_search.patbuf[LEN];; cp++)
 				    if (cp >= &el->el_search.patbuf[
 					el->el_search.patlen]) {
+					if (el->el_line.cursor ==
+					    el->el_line.buffer)
+						break;
 					el->el_line.cursor +=
 					    el->el_search.patlen - LEN - 1;
 					cp = c__next_word(el->el_line.cursor,

Reply via email to