Menu

#12 Segmentation fault occurs on substitution in 32-bit systems.

None
closed
None
5
2023-03-07
2022-02-07
No

Environment

  • Version: bvi 1.4.1
  • OS: Debian GNU/Linux (Bullseye) i686 [32bit], Cygwin 3.3.4 (i686) [32bit]

Overview

Substitution command causes segmentation fault in 32 bit systems.

How to reproduce the issue

  1. Start bvi in a 32-bit system.
  2. Enter :set mm
  3. Press 'A' and enter 0x41 four times at address 0 to 3 and press 'ESC' key.
  4. Enter :s/A/B/g
  5. Segmentation fault occurs.

The patch for this issue

diff --git a/re.c b/re.c
index bc5cdd8..160b25a 100644
--- a/re.c
+++ b/re.c
@@ -312,7 +312,7 @@ do_substitution(delim, line, startpos, endpos)
    refresh();

    if (global) {

-       if ((undo_count = alloc_buf(endpos - startpos, &undo_buf))) {
+       if ((undo_count = alloc_buf((off_t)(endpos - startpos), &undo_buf))) {
            memcpy(undo_buf, startpos + 1, undo_count);
        }
        undo_start = startpos + 1;
@@ -350,7 +350,7 @@ AGAIN:
        repl_count++;
        current_start = pagepos + y * Anzahl + xpos();
        if (!global) {
-           if ((undo_count = alloc_buf(pat_len, &undo_buf))) {
+           if ((undo_count = alloc_buf((off_t)pat_len, &undo_buf))) {
                memcpy(undo_buf, current_start, undo_count);
            }
            undo_start = current_start;

Discussion

  • Gerhard Buergmann

    • status: open --> closed
    • assigned_to: Gerhard Buergmann
    • Group: -->
     
  • Gerhard Buergmann

    Fixed in 1.4.2

     

Log in to post a comment.

MongoDB Logo MongoDB