summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-09-26 09:48:26 +0200
committerGravatar Martin Szulecki2013-09-26 09:48:26 +0200
commitafb8735176869db20219c35a341e89158651bffe (patch)
treea46dd916ab836b209f8c89465bc9294e57c6f72f
parent8dffdecf8fd5a080265b9b35e00091961bfd8648 (diff)
downloadlibirecovery-afb8735176869db20219c35a341e89158651bffe.tar.gz
libirecovery-afb8735176869db20219c35a341e89158651bffe.tar.bz2
Revert changes to return errors when sending commands, getenv or getret
This fixes software which did not expect to receive an error after sending specific commands. Sending "go" for instance returned a connection reset error which was interpreted as "could not send command" while this behavior is completely correct. This also fixes idevicerestore's "Unable to send iBEC" problems.
-rw-r--r--src/libirecovery.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index e82bce2..7aebc32 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -822,18 +822,16 @@ void irecv_set_debug_level(int level) {
822} 822}
823 823
824static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command) { 824static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command) {
825 int ret = 0;
826
827 unsigned int length = strlen(command); 825 unsigned int length = strlen(command);
828 if (length >= 0x100) { 826 if (length >= 0x100) {
829 length = 0xFF; 827 length = 0xFF;
830 } 828 }
831 829
832 if (length > 0) { 830 if (length > 0) {
833 ret = irecv_control_transfer(client, 0x40, 0, 0, 0, (unsigned char*) command, length + 1, USB_TIMEOUT); 831 irecv_control_transfer(client, 0x40, 0, 0, 0, (unsigned char*) command, length + 1, USB_TIMEOUT);
834 } 832 }
835 833
836 return ((unsigned)ret == (length + 1) ? IRECV_E_SUCCESS: IRECV_E_UNKNOWN_ERROR); 834 return IRECV_E_SUCCESS;
837} 835}
838 836
839irecv_error_t irecv_send_command(irecv_client_t client, const char* command) { 837irecv_error_t irecv_send_command(irecv_client_t client, const char* command) {
@@ -1077,7 +1075,6 @@ irecv_error_t irecv_receive(irecv_client_t client) {
1077} 1075}
1078 1076
1079irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** value) { 1077irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** value) {
1080 int ret = 0;
1081 char command[256]; 1078 char command[256];
1082 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; 1079 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
1083 *value = NULL; 1080 *value = NULL;
@@ -1102,15 +1099,14 @@ irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** v
1102 } 1099 }
1103 1100
1104 memset(response, '\0', 256); 1101 memset(response, '\0', 256);
1105 ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT); 1102 irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT);
1106 1103
1107 *value = response; 1104 *value = response;
1108 1105
1109 return (ret > 0 ? IRECV_E_SUCCESS: IRECV_E_UNKNOWN_ERROR); 1106 return IRECV_E_SUCCESS;
1110} 1107}
1111 1108
1112irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) { 1109irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) {
1113 int ret = 0;
1114 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; 1110 if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
1115 *value = 0; 1111 *value = 0;
1116 1112
@@ -1120,11 +1116,11 @@ irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) {
1120 } 1116 }
1121 1117
1122 memset(response, '\0', 256); 1118 memset(response, '\0', 256);
1123 ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT); 1119 irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT);
1124 1120
1125 *value = (unsigned int) *response; 1121 *value = (unsigned int) *response;
1126 1122
1127 return (ret > 0 ? IRECV_E_SUCCESS: IRECV_E_UNKNOWN_ERROR); 1123 return IRECV_E_SUCCESS;
1128} 1124}
1129 1125
1130irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) { 1126irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) {