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 ) ...@@ -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 ) 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 */ /* format: name[index].field */
char *field = strchr( name, '.' );
int i = 1 + (field != NULL) ? (field - name) : strlen( name );
char base[i];
char *p;
int i_index;
field = strchr( name, '.' ); strlcpy( base, name, i );
if( field ) if( field != NULL )
{
int i = field - name;
strncpy( base, name, i );
base[i] = '\0';
field++; field++;
}
else
{
strcpy( base, name );
}
if( ( p = strchr( base, '[' ) ) ) if( ( p = strchr( base, '[' ) ) != NULL )
{ {
*p++ = '\0'; *p++ = '\0';
sscanf( p, "%d]", &i_index ); 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