Patch to fix null termination of string buffer

archer_ame at yahoo.co.jp archer_ame at yahoo.co.jp
Tue Dec 13 11:18:27 UTC 2016


This is my first time to sending a patch to the mailing list.
So, I'm sorry if I did something wrong.

The function drmParsePciBusInfo() in xf86drm.c reads the contents of the file "/sys/dev/char/x:y/device/uevent" 
into the buffer.
The string written to the buffer by read() is not null-terminated, but this function is writing null only at the 
end of the buffer.
As a result, the string passed to sscanf() contains an uninitialized value and sscanf uses it.

For example,
The string that should be passed to sscanf().
"The contents of the file\0"

The string actually passed to sscanf().
"The contents of the file and uninitialized value until the end of the buffer\0"


More information about the dri-devel mailing list