dm: array bound and NULL pointer issue fix

Remove the possible NULL pointer access code for virtio-console.c
Add '\0' to end of native_patch[], to avoid the potential issue when
using %s to print the array for virtio-i2c.c

Tracked-On: #3467
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yonghua Huang <Yonghua.huang@intel.com>
This commit is contained in:
Conghui Chen
2019-07-25 10:08:50 +00:00
committed by ACRN System Integration
parent 9fef51abf9
commit 3945bc4c40
2 changed files with 3 additions and 1 deletions

View File

@@ -444,6 +444,8 @@ native_adapter_create(int bus, uint16_t slave_addr[], int n_slave)
}
snprintf(native_path, sizeof(native_path), "/dev/i2c-%d", bus);
native_path[sizeof(native_path) - 1] = '\0';
fd = open(native_path, O_RDWR);
if (fd < 0) {
WPRINTF("virtio_i2c: failed to open %s\n", native_path);