aboutsummaryrefslogtreecommitdiffstats
path: root/extendedcommands.c
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2012-10-12 00:14:47 -0700
committerKoushik Dutta <koushd@gmail.com>2012-10-12 00:14:47 -0700
commit470e3cdab82a70f079cc111be83ed61a4b86ebf7 (patch)
treeabb1ba8758ceb929cd09604abf5b8b7c7af57050 /extendedcommands.c
parentc4f037d085fce54376284ff2f69cc1a16609937a (diff)
downloadbootable_recovery-470e3cdab82a70f079cc111be83ed61a4b86ebf7.zip
bootable_recovery-470e3cdab82a70f079cc111be83ed61a4b86ebf7.tar.gz
bootable_recovery-470e3cdab82a70f079cc111be83ed61a4b86ebf7.tar.bz2
fix lack of null termination being written to the lun file
Change-Id: I51e2239c20c6b88a042c011b8807002491d759bc
Diffstat (limited to 'extendedcommands.c')
-rw-r--r--extendedcommands.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/extendedcommands.c b/extendedcommands.c
index 47bdcee..c9c37a3 100644
--- a/extendedcommands.c
+++ b/extendedcommands.c
@@ -442,8 +442,7 @@ static struct lun_node *lun_head = NULL;
static struct lun_node *lun_tail = NULL;
int control_usb_storage_set_lun(Volume* vol, bool enable, const char *lun_file) {
- char c = 0;
- const char *vol_device = enable ? vol->device : &c;
+ const char *vol_device = enable ? vol->device : "";
int fd;
struct lun_node *node;
@@ -463,7 +462,7 @@ int control_usb_storage_set_lun(Volume* vol, bool enable, const char *lun_file)
}
// Write the volume path to the LUN file
- if ((write(fd, vol_device, strlen(vol_device)) < 0) &&
+ if ((write(fd, vol_device, strlen(vol_device) + 1) < 0) &&
(!enable || !vol->device2 || (write(fd, vol->device2, strlen(vol->device2)) < 0))) {
LOGW("Unable to write to ums lunfile %s (%s)\n", lun_file, strerror(errno));
close(fd);