all: Fix overflow in shift operators
This commit is contained in:
1 parent
c86e130ab1
commit
bb90caec1b
4 files changed
+8
-8
No files matched your search
+1
-1
@@ -36,7 +36,7 @@
|
|||||||
#include "usb-device.h"
|
#include "usb-device.h"
|
||||||
#include "printf-utils.h"
|
#include "printf-utils.h"
|
||||||
|
|
||||||
static char global_buf[1 << 22]; /* 4MB */
|
static char global_buf[1UL << 22]; /* 4MB */
|
||||||
|
|
||||||
int disk_open_dev(int maj, int min, int partition, int readonly) {
|
int disk_open_dev(int maj, int min, int partition, int readonly) {
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -145,7 +145,7 @@ int mkii_init(struct usb_device_info * dev) {
|
|||||||
}
|
}
|
||||||
type = image_type_from_string(ptr);
|
type = image_type_from_string(ptr);
|
||||||
if ( type != IMAGE_UNKNOWN ) {
|
if ( type != IMAGE_UNKNOWN ) {
|
||||||
dev->data |= (1 << type);
|
dev->data |= (1UL << type);
|
||||||
printf(" %s", ptr);
|
printf(" %s", ptr);
|
||||||
}
|
}
|
||||||
ptr = newptr;
|
ptr = newptr;
|
||||||
@@ -156,9 +156,9 @@ int mkii_init(struct usb_device_info * dev) {
|
|||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
usb_get_string_simple(dev->udev, usb_device(dev->udev)->config[dev->flash_device->configuration].iConfiguration, buf, sizeof(buf));
|
usb_get_string_simple(dev->udev, usb_device(dev->udev)->config[dev->flash_device->configuration].iConfiguration, buf, sizeof(buf));
|
||||||
if ( strncmp(buf, "Firmware Upgrade Configuration", sizeof("Firmware Upgrade Configuration")) == 0 )
|
if ( strncmp(buf, "Firmware Upgrade Configuration", sizeof("Firmware Upgrade Configuration")) == 0 )
|
||||||
dev->data |= (1 << 31);
|
dev->data |= (1UL << 31);
|
||||||
|
|
||||||
printf("Mode: %s\n", (dev->data & (1<<31)) ? "Update" : "PC Suite");
|
printf("Mode: %s\n", (dev->data & (1UL << 31)) ? "Update" : "PC Suite");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ int mkii_flash_image(struct usb_device_info * dev, struct image * image) {
|
|||||||
ERROR("Not implemented yet");
|
ERROR("Not implemented yet");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ( ! ( dev->data & (1 << image->type) ) ) {
|
if ( ! ( dev->data & (1UL << image->type) ) ) {
|
||||||
ERROR("Flashing image %s is not supported in current device configuration", image_type_to_string(image->type));
|
ERROR("Flashing image %s is not supported in current device configuration", image_type_to_string(image->type));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -180,7 +180,7 @@ int dev_flash_image(struct device_info * dev, struct image * image) {
|
|||||||
usb_switch_to_update(dev->usb);
|
usb_switch_to_update(dev->usb);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
} else if ( protocol == FLASH_MKII ) {
|
} else if ( protocol == FLASH_MKII ) {
|
||||||
if ( dev->usb->data & (1 << image->type) )
|
if ( dev->usb->data & (1UL << image->type) )
|
||||||
return mkii_flash_image(dev->usb, image);
|
return mkii_flash_image(dev->usb, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -384,7 +384,7 @@ void usb_switch_to_update(struct usb_device_info * dev) {
|
|||||||
leave_cold_flash(dev);
|
leave_cold_flash(dev);
|
||||||
else if ( dev->flash_device->protocol == FLASH_NOLO )
|
else if ( dev->flash_device->protocol == FLASH_NOLO )
|
||||||
nolo_boot_device(dev, "update");
|
nolo_boot_device(dev, "update");
|
||||||
else if ( dev->flash_device->protocol == FLASH_MKII && ! ( dev->data & ( 1 << 31 ) ) )
|
else if ( dev->flash_device->protocol == FLASH_MKII && ! ( dev->data & ( 1UL << 31 ) ) )
|
||||||
mkii_reboot_device(dev);
|
mkii_reboot_device(dev);
|
||||||
else if ( dev->flash_device->protocol == FLASH_DISK )
|
else if ( dev->flash_device->protocol == FLASH_DISK )
|
||||||
printf_and_wait("Unplug USB cable, turn device off, press ENTER and plug USB cable again");
|
printf_and_wait("Unplug USB cable, turn device off, press ENTER and plug USB cable again");
|
||||||
@@ -401,7 +401,7 @@ void usb_switch_to_disk(struct usb_device_info * dev) {
|
|||||||
nolo_boot_device(dev, NULL);
|
nolo_boot_device(dev, NULL);
|
||||||
printf_and_wait("Wait until device start, choose USB Mass Storage Mode and press ENTER");
|
printf_and_wait("Wait until device start, choose USB Mass Storage Mode and press ENTER");
|
||||||
} else if ( dev->flash_device->protocol == FLASH_MKII ) {
|
} else if ( dev->flash_device->protocol == FLASH_MKII ) {
|
||||||
if ( dev->data & ( 1 << 31 ) )
|
if ( dev->data & ( 1UL << 31 ) )
|
||||||
mkii_reboot_device(dev);
|
mkii_reboot_device(dev);
|
||||||
else
|
else
|
||||||
printf_and_wait("Unplug USB cable, plug again, choose USB Mass Storage Mode and press ENTER");
|
printf_and_wait("Unplug USB cable, plug again, choose USB Mass Storage Mode and press ENTER");
|
||||||
|
|||||||
Reference in new issue
Block a user