summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-03-14 10:41:52 +0100
committerGravatar Nikias Bassen2014-03-14 10:41:52 +0100
commit613ec55ae6441c0177859ac7f49b92a133979465 (patch)
treeb15232d9b3f5a71f2f2b7ace53e681dc94730b78
parent00ab62a8ea9518b73f1ad98fbbf504b9d54d920c (diff)
downloadideviceinstaller-613ec55ae6441c0177859ac7f49b92a133979465.tar.gz
ideviceinstaller-613ec55ae6441c0177859ac7f49b92a133979465.tar.bz2
Fix possible buffer overflow (thanks to Mikkel Kamstrup for pointing that out!)
-rw-r--r--src/ideviceinstaller.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c
index 81ce145..e1f995b 100644
--- a/src/ideviceinstaller.c
+++ b/src/ideviceinstaller.c
@@ -913,8 +913,7 @@ run_again:
913 zbuf = NULL; 913 zbuf = NULL;
914 len = 0; 914 len = 0;
915 plist_t info = NULL; 915 plist_t info = NULL;
916 char filename[256]; 916 char* filename = NULL;
917 filename[0] = '\0';
918 char* app_directory_name = NULL; 917 char* app_directory_name = NULL;
919 918
920 if (zip_get_app_directory(zf, &app_directory_name)) { 919 if (zip_get_app_directory(zf, &app_directory_name)) {
@@ -923,6 +922,7 @@ run_again:
923 } 922 }
924 923
925 /* construct full filename to Info.plist */ 924 /* construct full filename to Info.plist */
925 filename = (char*)malloc(strlen(app_directory_name)+10+1);
926 strcpy(filename, app_directory_name); 926 strcpy(filename, app_directory_name);
927 free(app_directory_name); 927 free(app_directory_name);
928 app_directory_name = NULL; 928 app_directory_name = NULL;
@@ -930,10 +930,12 @@ run_again:
930 930
931 if (zip_get_contents(zf, filename, 0, &zbuf, &len) < 0) { 931 if (zip_get_contents(zf, filename, 0, &zbuf, &len) < 0) {
932 fprintf(stderr, "WARNING: could not locate %s in archive!\n", filename); 932 fprintf(stderr, "WARNING: could not locate %s in archive!\n", filename);
933 free(filename);
933 zip_unchange_all(zf); 934 zip_unchange_all(zf);
934 zip_close(zf); 935 zip_close(zf);
935 goto leave_cleanup; 936 goto leave_cleanup;
936 } 937 }
938 free(filename);
937 if (memcmp(zbuf, "bplist00", 8) == 0) { 939 if (memcmp(zbuf, "bplist00", 8) == 0) {
938 plist_from_bin(zbuf, len, &info); 940 plist_from_bin(zbuf, len, &info);
939 } else { 941 } else {