Commit af2fdf1b authored by arsharma's avatar arsharma Committed by Adam Jackson
Browse files

vgaarb: add a the trailing NULL character on read(vgaarb_fd)



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's avatarEmil Velikov <emil.l.velikov@gmail.com>
parent c1de5dc0
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment