[PATCH libpciaccess 1/2] vgaarb: add a the trailing NULL character on read(vgaarb_fd)
Emil Velikov
emil.l.velikov at gmail.com
Fri Mar 6 12:09:58 PST 2015
Another humble ping. Can we get any comments on these two patches ?
Thanks
Emil
On 27 February 2015 at 16:16, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> Humble ping ?
>
> On 23 February 2015 at 21:31, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>> From: arsharma <ankitprasad.r.sharma at intel.com>
>>
>> Issue was spotted by Klocwork, and fixed by arsharma as part of
>> Android-ia. Not 100% sure if the data read from /dev/vga_arbiter is not
>> already null terminated, but making sure won't hurt either.
>>
>> [Emil Velikov: Split from larger patch, write commit message]
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>> src/common_vgaarb.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
>> index 7a7d204..515275f 100644
>> --- a/src/common_vgaarb.c
>> +++ b/src/common_vgaarb.c
>> @@ -126,7 +126,7 @@ int
>> pci_device_vgaarb_init(void)
>> {
>> struct pci_slot_match match;
>> - char buf[BUFSIZE];
>> + char buf[BUFSIZE + 1]; /* reading BUFSIZE characters, + 1 for NULL */
>> int ret, rsrc;
>>
>> if (!pci_sys)
>> @@ -140,6 +140,8 @@ pci_device_vgaarb_init(void)
>> if (ret <= 0)
>> return -1;
>>
>> + buf[ret] = 0; /* ret will never be greater than BUFSIZE */
>> +
>> memset(&match, 0xff, sizeof(match));
>> /* need to find the device to go back to and what it was decoding */
>> rsrc = parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, &match);
>> @@ -226,7 +228,7 @@ int
>> pci_device_vgaarb_set_target(struct pci_device *dev)
>> {
>> int len;
>> - char buf[BUFSIZE];
>> + char buf[BUFSIZE + 1]; /* reading BUFSIZE characters, + 1 for NULL */
>> int ret;
>>
>> if (!dev)
>> @@ -245,6 +247,8 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
>> if (ret <= 0)
>> return -1;
>>
>> + buf[ret] = 0; /* ret will never be greater than BUFSIZE */
>> +
>> dev->vgaarb_rsrc = parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, NULL);
>> pci_sys->vga_target = dev;
>> return 0;
>> @@ -254,7 +258,7 @@ int
>> pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
>> {
>> int len;
>> - char buf[BUFSIZE];
>> + char buf[BUFSIZE + 1]; /* reading BUFSIZE characters, + 1 for NULL */
>> int ret;
>> struct pci_device *dev = pci_sys->vga_target;
>>
>> @@ -272,6 +276,8 @@ pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
>> if (ret <= 0)
>> return -1;
>>
>> + buf[ret] = 0; /* ret will never be greater than BUFSIZE */
>> +
>> parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, NULL);
>>
>> return ret;
>> --
>> 2.3.0
>>
More information about the xorg-devel
mailing list