diff options
author | Matthieu Herrb <matthieu@herrb.eu> | 2016-05-16 10:09:18 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu@herrb.eu> | 2016-05-16 10:09:18 +0200 |
commit | c8a829902989bc360a21fde784e7efd9fbb2c4a4 (patch) | |
tree | c1e8a1e841df6a522b5e617ac9dd2517fff7e196 | |
parent | be4eab40bf619bd7a0971f8b846b5e72b870d769 (diff) | |
parent | 201d1a7623c83f611761f67d4411c3c266f8f37a (diff) |
Merge remote-tracking branch 'origin/master' into obsd
-rw-r--r-- | src/common_device_name.c | 10 | ||||
-rw-r--r-- | src/common_vgaarb.c | 12 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/common_device_name.c b/src/common_device_name.c index a990ac8..3dd35d7 100644 --- a/src/common_device_name.c +++ b/src/common_device_name.c @@ -154,6 +154,10 @@ insert( uint16_t vendor ) if ( tree == NULL ) { tree = calloc( 1, sizeof( struct pci_id_node ) ); + + if ( tree == NULL ) + return NULL; + tree->bits = 4; } @@ -175,6 +179,9 @@ insert( uint16_t vendor ) struct pci_id_node * child = calloc( 1, sizeof( struct pci_id_node ) ); + if ( tree == NULL ) + return NULL; + child->bits = 4; n->children[ idx ] = child; @@ -183,6 +190,9 @@ insert( uint16_t vendor ) struct pci_id_leaf * leaf = calloc( 1, sizeof( struct pci_id_leaf ) ); + if ( tree == NULL ) + return NULL; + leaf->vendor = vendor; n->children[ idx ] = (struct pci_id_node *) leaf; 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; |