Make sure we don't look before the beginning of the string.

NetBSD Rev 1.5

Reviewed by:		phk
Obtained from:		NetBSD
This commit is contained in:
mbr 2003-01-27 22:36:53 +00:00
parent e61117f9e2
commit 5a16f354fd

View File

@ -249,9 +249,9 @@ int token; /* char to parse string for */
/*
* did find a token, but it might be escaped.
*/
if (cp[-1] == '\\') {
if ((cp > npp) && (cp[-1] == '\\')) {
/* if slash was also escaped, carry on, otherwise find next token */
if (cp[-2] != '\\') {
if ((cp > npp + 1) && (cp[-2] != '\\')) {
/* shift r-o-s onto the escaped token */
strcpy(&cp[-1], cp); /* XXX: overlapping string copy */
/*