fix potential memory overwrite in escape parsing

PR: 11687
Submitted by: Don Lewis <Don.Lewis@tsc.tdk.com>
This commit is contained in:
Andrey A. Chernov 1999-05-13 16:16:46 +00:00
parent 6d9c684ab7
commit 121ba32d78
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=47118

View File

@ -21,7 +21,7 @@
*
* High-level routines relating to use of the user capabilities database
*
* $Id: login_class.c,v 1.9 1998/07/28 01:30:16 ache Exp $
* $Id: login_class.c,v 1.10 1998/07/29 14:05:01 ache Exp $
*/
#include <stdio.h>
@ -163,7 +163,7 @@ substvar(char * var, const struct passwd * pwd, int hlen, int pch, int nlen)
while (*(p += strcspn(p, "~$")) != '\0') {
int l = strlen(p);
if (p > var && *(p-1) == '\\') /* Escaped: */
if (p > np && *(p-1) == '\\') /* Escaped: */
memmove(p - 1, p, l + 1); /* Slide-out the backslash */
else if (*p == '~') {
int v = pch && *(p+1) != '/'; /* Avoid double // */