* util.c (convert_controls): Fix possible buffer overflow

for ".*^" strings.
This commit is contained in:
Andrew V. Samoilov 2004-09-28 09:28:57 +00:00
parent 49117d0f31
commit 7d393abc2c
2 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2004-09-28 Andrew V. Samoilov <sav@bcs.zp.ua>
* util.c (convert_controls): Fix possible buffer overflow
for ".*^" strings.
2004-09-27 Andrew V. Samoilov <sav@bcs.zp.ua>
* complete.c [__linux__ && !__USE_GNU]: Fix compilation on Red Hat 7.3

View File

@ -1019,14 +1019,13 @@ void wipe_password (char *passwd)
/* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */
/* Returns a newly allocated string */
char *convert_controls (const char *s)
char *convert_controls (const char *p)
{
char *valcopy = g_strdup (s);
const char *p;
char *valcopy = g_strdup (p);
char *q;
/* Parse the escape special character */
for (p = s, q = valcopy; *p;){
for (q = valcopy; *p;){
if (*p == '\\'){
p++;
if ((*p == 'e') || (*p == 'E')){
@ -1043,7 +1042,7 @@ char *convert_controls (const char *s)
if (c >= 'a' && c <= 'z') {
*q++ = c - 'a' + 1;
p++;
} else
} else if (*p)
p++;
}
} else