Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testcases/cve/meltdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ find_kernel_symbol(const char *name)

if (uname(&utsname) < 0)
tst_brk(TBROK | TERRNO, "uname");
sprintf(systemmap, "/boot/System.map-%s", utsname.release);
snprintf(systemmap, sizeof(systemmap), "/boot/System.map-%s", utsname.release);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemmap is supposed to be null terminated. So you must reserve one byte for null and set it to zero.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually as far as I can tell snprintf() always null terminates the output buffer, unless of course the buffer size passed is 0. So this patch looks good to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I've update the comment.

addr = find_symbol_in_file(systemmap, name);
return addr;
}
Expand Down