diff options
author | Martin Szulecki | 2013-11-06 00:21:27 +0100 |
---|---|---|
committer | Martin Szulecki | 2013-11-06 00:25:20 +0100 |
commit | afb16e212dbd0cbca3b1987cc4ec772005436a81 (patch) | |
tree | cc248a177417560ca1ef674baa5a15a65abdc417 /src/libirecovery.c | |
parent | 1729b43830d98af3f1b5edc457e3b7c14e637cab (diff) | |
download | libirecovery-afb16e212dbd0cbca3b1987cc4ec772005436a81.tar.gz libirecovery-afb16e212dbd0cbca3b1987cc4ec772005436a81.tar.bz2 |
Fix lookup of a device by hardware model if input is not a lowercase string
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r-- | src/libirecovery.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index 29a0494..3410c8a 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> #include <unistd.h> #ifndef WIN32 @@ -1600,8 +1601,14 @@ irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_mo *device = NULL; + /* lowercase hardware_model string for proper lookup */ + char model[8]; + strcpy(model, hardware_model); + char *p = model; + for (; *p; ++p) *p = tolower(*p); + for (i = 0; irecv_devices[i].hardware_model != NULL; i++) { - if (!strcmp(hardware_model, irecv_devices[i].hardware_model)) { + if (!strcmp(model, irecv_devices[i].hardware_model)) { *device = &irecv_devices[i]; return IRECV_E_SUCCESS; } |