diff options
author | 2023-05-01 19:11:25 +0200 | |
---|---|---|
committer | 2023-05-01 19:11:25 +0200 | |
commit | 1480e2b681cc6cbf822f7d9e27640492f4f57a9b (patch) | |
tree | 55c519a32d69e6067172d8e9c74b6be5734f92db | |
parent | 1d20bed9ab853507b013e0ab0fdfa11be393d1e0 (diff) | |
download | libirecovery-1480e2b681cc6cbf822f7d9e27640492f4f57a9b.tar.gz libirecovery-1480e2b681cc6cbf822f7d9e27640492f4f57a9b.tar.bz2 |
Fix a few buffer sizes and their initialization
-rw-r--r-- | src/libirecovery.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index 316feab..fc1e2cf 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c | |||
@@ -574,12 +574,12 @@ static int irecv_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc | |||
574 | #else | 574 | #else |
575 | irecv_error_t ret; | 575 | irecv_error_t ret; |
576 | unsigned short langid = 0; | 576 | unsigned short langid = 0; |
577 | unsigned char data[255]; | 577 | unsigned char data[256]; |
578 | int di, si; | 578 | int di, si; |
579 | memset(data, 0, sizeof(data)); | 579 | memset(data, 0, 256); |
580 | memset(buffer, 0, size); | 580 | memset(buffer, 0, size); |
581 | 581 | ||
582 | ret = irecv_usb_control_transfer(client, 0x80, 0x06, (0x03 << 8) | desc_index, langid, data, sizeof(data), USB_TIMEOUT); | 582 | ret = irecv_usb_control_transfer(client, 0x80, 0x06, (0x03 << 8) | desc_index, langid, data, 255, USB_TIMEOUT); |
583 | 583 | ||
584 | if (ret < 0) return ret; | 584 | if (ret < 0) return ret; |
585 | if (data[1] != 0x03) return IRECV_E_UNKNOWN_ERROR; | 585 | if (data[1] != 0x03) return IRECV_E_UNKNOWN_ERROR; |
@@ -688,12 +688,13 @@ static void irecv_copy_nonce_with_tag(irecv_client_t client, const char* tag, un | |||
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | 690 | ||
691 | char buf[255]; | 691 | char buf[256]; |
692 | int len; | 692 | int len; |
693 | 693 | ||
694 | *nonce = NULL; | 694 | *nonce = NULL; |
695 | *nonce_size = 0; | 695 | *nonce_size = 0; |
696 | 696 | ||
697 | memset(buf, 0, 256); | ||
697 | len = irecv_get_string_descriptor_ascii(client, 1, (unsigned char*) buf, 255); | 698 | len = irecv_get_string_descriptor_ascii(client, 1, (unsigned char*) buf, 255); |
698 | if (len < 0) { | 699 | if (len < 0) { |
699 | debug("%s: got length: %d\n", __func__, len); | 700 | debug("%s: got length: %d\n", __func__, len); |
@@ -834,7 +835,6 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) { | |||
834 | } | 835 | } |
835 | 836 | ||
836 | char serial_str[256]; | 837 | char serial_str[256]; |
837 | |||
838 | serial_str[0] = '\0'; | 838 | serial_str[0] = '\0'; |
839 | 839 | ||
840 | char *p = result; | 840 | char *p = result; |
@@ -1495,6 +1495,7 @@ IRECV_API irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, uint64_t e | |||
1495 | client->mode = usb_descriptor.idProduct; | 1495 | client->mode = usb_descriptor.idProduct; |
1496 | 1496 | ||
1497 | char serial_str[256]; | 1497 | char serial_str[256]; |
1498 | memset(serial_str, 0, 256); | ||
1498 | irecv_get_string_descriptor_ascii(client, usb_descriptor.iSerialNumber, (unsigned char*)serial_str, 255); | 1499 | irecv_get_string_descriptor_ascii(client, usb_descriptor.iSerialNumber, (unsigned char*)serial_str, 255); |
1499 | 1500 | ||
1500 | irecv_load_device_info_from_iboot_string(client, serial_str); | 1501 | irecv_load_device_info_from_iboot_string(client, serial_str); |
@@ -1939,7 +1940,7 @@ static void* _irecv_handle_device_add(void *userdata) | |||
1939 | uint32_t location = 0; | 1940 | uint32_t location = 0; |
1940 | uint16_t product_id = 0; | 1941 | uint16_t product_id = 0; |
1941 | 1942 | ||
1942 | serial_str[0] = '\0'; | 1943 | memset(serial_str, 0, 256); |
1943 | #ifdef WIN32 | 1944 | #ifdef WIN32 |
1944 | struct irecv_win_dev_ctx *win_ctx = (struct irecv_win_dev_ctx*)userdata; | 1945 | struct irecv_win_dev_ctx *win_ctx = (struct irecv_win_dev_ctx*)userdata; |
1945 | PSP_DEVICE_INTERFACE_DETAIL_DATA details = win_ctx->details; | 1946 | PSP_DEVICE_INTERFACE_DETAIL_DATA details = win_ctx->details; |