Commit 64b79790 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix likely stack buffer overflow

parent 0627abcd
......@@ -126,26 +126,18 @@ void E_(mvar_RemoveVar)( mvar_t *v, mvar_t *f )
mvar_t *E_(mvar_GetVar)( mvar_t *s, const char *name )
{
int i;
char base[512], *field, *p;
int i_index;
/* format: name[index].field */
field = strchr( name, '.' );
if( field )
{
int i = field - name;
strncpy( base, name, i );
base[i] = '\0';
char *field = strchr( name, '.' );
int i = 1 + (field != NULL) ? (field - name) : strlen( name );
char base[i];
char *p;
int i_index;
strlcpy( base, name, i );
if( field != NULL )
field++;
}
else
{
strcpy( base, name );
}
if( ( p = strchr( base, '[' ) ) )
if( ( p = strchr( base, '[' ) ) != NULL )
{
*p++ = '\0';
sscanf( p, "%d]", &i_index );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment