diff options
Diffstat (limited to 'fastboot')
-rw-r--r-- | fastboot/engine.c | 8 | ||||
-rw-r--r-- | fastboot/fastboot.c | 1 | ||||
-rw-r--r-- | fastboot/usb_linux.c | 9 | ||||
-rw-r--r-- | fastboot/usb_windows.c | 5 |
4 files changed, 18 insertions, 5 deletions
diff --git a/fastboot/engine.c b/fastboot/engine.c index 8ba202c..48073ee 100644 --- a/fastboot/engine.c +++ b/fastboot/engine.c @@ -97,14 +97,20 @@ static Action *queue_action(unsigned op, const char *fmt, ...) { Action *a; va_list ap; + size_t cmdsize; a = calloc(1, sizeof(Action)); if (a == 0) die("out of memory"); va_start(ap, fmt); - vsprintf(a->cmd, fmt, ap); + cmdsize = vsnprintf(a->cmd, sizeof(a->cmd), fmt, ap); va_end(ap); + if (cmdsize >= sizeof(a->cmd)) { + free(a); + die("Command length (%d) exceeds maximum size (%d)", cmdsize, sizeof(a->cmd)); + } + if (action_last) { action_last->next = a; } else { diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c index f3bfbeba..14048a1 100644 --- a/fastboot/fastboot.c +++ b/fastboot/fastboot.c @@ -223,6 +223,7 @@ void usage(void) " boot <kernel> [ <ramdisk> ] download and boot kernel\n" " flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it\n" " devices list all connected devices\n" + " continue continue with autoboot\n" " reboot reboot device normally\n" " reboot-bootloader reboot device into bootloader\n" "\n" diff --git a/fastboot/usb_linux.c b/fastboot/usb_linux.c index 78b7b98..1ba87e6 100644 --- a/fastboot/usb_linux.c +++ b/fastboot/usb_linux.c @@ -61,6 +61,11 @@ #define DBG1(x...) #endif +/* The max bulk size for linux is 16384 which is defined + * in drivers/usb/core/devio.c. + */ +#define MAX_USBFS_BULK_SIZE (16 * 1024) + struct usb_handle { char fname[64]; @@ -289,7 +294,7 @@ int usb_write(usb_handle *h, const void *_data, int len) while(len > 0) { int xfer; - xfer = (len > 4096) ? 4096 : len; + xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len; bulk.ep = h->ep_out; bulk.len = xfer; @@ -323,7 +328,7 @@ int usb_read(usb_handle *h, void *_data, int len) } while(len > 0) { - int xfer = (len > 4096) ? 4096 : len; + int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len; bulk.ep = h->ep_in; bulk.len = xfer; diff --git a/fastboot/usb_windows.c b/fastboot/usb_windows.c index 54008a4..1050293 100644 --- a/fastboot/usb_windows.c +++ b/fastboot/usb_windows.c @@ -42,6 +42,7 @@ #define DBG(x...) #endif +#define MAX_USBFS_BULK_SIZE (1024 * 1024) /** Structure usb_handle describes our connection to the usb device via AdbWinApi.dll. This structure is returned from usb_open() routine and @@ -160,7 +161,7 @@ int usb_write(usb_handle* handle, const void* data, int len) { if (NULL != handle) { // Perform write while(len > 0) { - int xfer = (len > 4096) ? 4096 : len; + int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len; ret = AdbWriteEndpointSync(handle->adb_write_pipe, (void*)data, (unsigned long)xfer, @@ -200,7 +201,7 @@ int usb_read(usb_handle *handle, void* data, int len) { DBG("usb_read %d\n", len); if (NULL != handle) { while (1) { - int xfer = (len > 4096) ? 4096 : len; + int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len; ret = AdbReadEndpointSync(handle->adb_read_pipe, (void*)data, |