From 48cd1b6c3b51a7bc6d45d4aeb7ff8c55d97a6f2a Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sun, 7 Dec 2014 11:06:07 -0800 Subject: 33894: boundary conditions in unmeta(), unmetafy() Check that we aren't running off the end of the string when converting the next byte after a Meta byte. This is just defensive programming in case of bad metafied strings coming through from gettokstr(), some repairs there are likely still needed. --- Src/utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 926814759..5c90638a2 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4164,7 +4164,7 @@ unmetafy(char *s, int *len) for (p = s; *p && *p != Meta; p++); for (t = p; (*t = *p++);) - if (*t++ == Meta) + if (*t++ == Meta && *p) t[-1] = *p++ ^ 32; if (len) *len = t - s; @@ -4208,8 +4208,10 @@ unmeta(const char *file_name) meta = 0; for (t = file_name; *t; t++) { - if (*t == Meta) - meta = 1; + if (*t == Meta) { + meta = t[1]; + break; + } } if (!meta) { /* -- cgit 1.4.1