[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.c |
Date: |
Wed, 19 Aug 2015 19:54:29 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 15/08/19 19:54:29
Modified files:
. : qe.c
Log message:
modes: fix bug in probe_mode, buffer was not NUL terminated
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.203&r2=1.204
Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -b -r1.203 -r1.204
--- qe.c 19 Aug 2015 19:20:57 -0000 1.203
+++ qe.c 19 Aug 2015 19:54:29 -0000 1.204
@@ -5881,6 +5881,7 @@
splitpath(buf, buf_size, NULL, 0, buf1);
}
+/* should have: rawbuf[len] == '\0' */
static int probe_mode(EditState *s, EditBuffer *b,
ModeDef **modes, int nb_modes,
int *scores, int min_score,
@@ -5940,9 +5941,10 @@
bufp += utf8_encode((char *)bufp, ch);
if (bufp > buf + sizeof(buf) - MAX_CHAR_BYTES - 1)
break;
+ }
probe_data.buf = buf;
probe_data.buf_size = bufp - buf;
- }
+ *bufp = '\0';
}
/* Skip the BOM if present */
@@ -6002,7 +6004,8 @@
int i, nb, found;
EditBuffer *b = s->b;
- size = eb_read(b, 0, buf, sizeof(buf));
+ size = eb_read(b, 0, buf, sizeof(buf) - 1);
+ buf[size] = '\0';
nb = probe_mode(s, b, modes, countof(modes), scores, 2,
b->filename, b->st_mode, b->total_size,