mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8235489: handle return values of sscanf calls in hotspot
Reviewed-by: clanger, kbarrett
This commit is contained in:
parent
3fe949b2f4
commit
e5b0e366ea
2 changed files with 11 additions and 6 deletions
|
@ -2081,11 +2081,14 @@ int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *pa
|
|||
u8 base, top, offset, inode;
|
||||
char permissions[5];
|
||||
char device[6];
|
||||
char name[PATH_MAX + 1];
|
||||
char name[sizeof(line)];
|
||||
|
||||
// Parse fields from line
|
||||
sscanf(line, UINT64_FORMAT_X "-" UINT64_FORMAT_X " %4s " UINT64_FORMAT_X " %7s " INT64_FORMAT " %s",
|
||||
int matches = sscanf(line, UINT64_FORMAT_X "-" UINT64_FORMAT_X " %4s " UINT64_FORMAT_X " %5s " INT64_FORMAT " %s",
|
||||
&base, &top, permissions, &offset, device, &inode, name);
|
||||
// the last entry 'name' is empty for some entries, so we might have 6 matches instead of 7 for some lines
|
||||
if (matches < 6) continue;
|
||||
if (matches == 6) name[0] = '\0';
|
||||
|
||||
// Filter by device id '00:00' so that we only get file system mapped files.
|
||||
if (strcmp(device, "00:00") != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue