fix /proc/#/maps parse faliures, formatting cleanup
This commit is contained in:
@@ -199,7 +199,7 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
int file_used = 0;
|
||||
bool eof = false;
|
||||
int got = 0;
|
||||
while(!eof && got < size-1 )
|
||||
while( !eof && got < size-1 )
|
||||
{
|
||||
int ret = read( fd, file+file_used, sizeof(file) - file_used);
|
||||
if( ret < int(sizeof(file)) - file_used)
|
||||
@@ -215,41 +215,38 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
break;
|
||||
*p++ = 0;
|
||||
|
||||
char line[1024];
|
||||
strcpy( line, file );
|
||||
memmove(file, p, file_used);
|
||||
file_used -= p-file;
|
||||
|
||||
/* Search for the hyphen. */
|
||||
char *hyphen = strchr( file, '-' );
|
||||
char *hyphen = strchr( line, '-' );
|
||||
if( hyphen == NULL )
|
||||
{
|
||||
/* Parse error. */
|
||||
continue;
|
||||
}
|
||||
continue; /* Parse error. */
|
||||
|
||||
|
||||
/* Search for the space. */
|
||||
char *space = strchr( hyphen, ' ' );
|
||||
if( space == NULL )
|
||||
{
|
||||
/* Parse error. */
|
||||
continue;
|
||||
}
|
||||
continue; /* Parse error. */
|
||||
|
||||
/* " rwxp". If space[1] isn't 'r', then the block isn't readable. */
|
||||
if( strlen(space) < 2 || space[1] != 'r' )
|
||||
continue;
|
||||
|
||||
*starts++ = (const void *) xtoi( file );
|
||||
*starts++ = (const void *) xtoi( line );
|
||||
*ends++ = (const void *) xtoi( hyphen+1 );
|
||||
|
||||
file_used -= p-file;
|
||||
memmove(file, p, file_used);
|
||||
}
|
||||
|
||||
if( file_used == sizeof(file) )
|
||||
{
|
||||
/* Line longer than the buffer. Weird; bail. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*starts++ = NULL;
|
||||
*ends++ = NULL;
|
||||
|
||||
Reference in New Issue
Block a user