prevent buffer underrun reads, ok bsiegert@

This commit is contained in:
tg 2009-11-22 13:49:04 +00:00
parent 2094e3f25c
commit ccc6f6de86

4
eval.c
View File

@ -22,7 +22,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.73 2009/11/21 23:23:17 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.74 2009/11/22 13:49:04 tg Exp $");
/* /*
* string expansion * string expansion
@ -1173,7 +1173,7 @@ trimsub(char *str, char *pat, int how)
goto trimsub_match; goto trimsub_match;
if (UTFMODE) { if (UTFMODE) {
char *op = p; char *op = p;
while ((*--p & 0xC0) == 0x80) while ((p-- > str) && ((*p & 0xC0) == 0x80))
; ;
if ((p < str) || (p + utf_ptradj(p) != op)) if ((p < str) || (p + utf_ptradj(p) != op))
p = op - 1; p = op - 1;