fix /proc/#/maps parse faliures, formatting cleanup

This commit is contained in:
Glenn Maynard
2004-01-02 04:13:43 +00:00
parent a9985795a4
commit eb63dc754f
+13 -16
View File
@@ -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;