summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Aaron Burghardt2014-08-24 21:17:47 -0400
committerGravatar Aaron Burghardt2014-08-25 06:01:43 -0400
commit5fecc039a7660aabe27304e3479f5ff4c7fd4bab (patch)
tree03d43dc34e55cdade9ccecdeee0b0eca83ca3e47 /src
parent8e96f2af5960f4f5e4b52e4d7fe4e3c0ff2fe655 (diff)
downloadlibimobiledevice-5fecc039a7660aabe27304e3479f5ff4c7fd4bab.tar.gz
libimobiledevice-5fecc039a7660aabe27304e3479f5ff4c7fd4bab.tar.bz2
afc.c: fixed leaks in various functions when an invalid argument error is returned.
Diffstat (limited to 'src')
-rw-r--r--src/afc.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/afc.c b/src/afc.c
index 7304d97..1263eb9 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -531,13 +531,13 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path)
531 531
532afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) 532afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to)
533{ 533{
534 if (!client || !from || !to || !client->afc_packet || !client->parent)
535 return AFC_E_INVALID_ARG;
536
534 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); 537 char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
535 uint32_t bytes = 0; 538 uint32_t bytes = 0;
536 afc_error_t ret = AFC_E_UNKNOWN_ERROR; 539 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
537 540
538 if (!client || !from || !to || !client->afc_packet || !client->parent)
539 return AFC_E_INVALID_ARG;
540
541 afc_lock(client); 541 afc_lock(client);
542 542
543 /* Send command */ 543 /* Send command */
@@ -910,14 +910,14 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new
910 910
911afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) 911afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize)
912{ 912{
913 if (!client || !path || !client->afc_packet || !client->parent)
914 return AFC_E_INVALID_ARG;
915
913 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 916 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
914 uint32_t bytes = 0; 917 uint32_t bytes = 0;
915 uint64_t size_requested = htole64(newsize); 918 uint64_t size_requested = htole64(newsize);
916 afc_error_t ret = AFC_E_UNKNOWN_ERROR; 919 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
917 920
918 if (!client || !path || !client->afc_packet || !client->parent)
919 return AFC_E_INVALID_ARG;
920
921 afc_lock(client); 921 afc_lock(client);
922 922
923 /* Send command */ 923 /* Send command */
@@ -940,14 +940,14 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize
940 940
941afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) 941afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
942{ 942{
943 if (!client || !target || !linkname || !client->afc_packet || !client->parent)
944 return AFC_E_INVALID_ARG;
945
943 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); 946 char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8));
944 uint32_t bytes = 0; 947 uint32_t bytes = 0;
945 uint64_t type = htole64(linktype); 948 uint64_t type = htole64(linktype);
946 afc_error_t ret = AFC_E_UNKNOWN_ERROR; 949 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
947 950
948 if (!client || !target || !linkname || !client->afc_packet || !client->parent)
949 return AFC_E_INVALID_ARG;
950
951 afc_lock(client); 951 afc_lock(client);
952 952
953 debug_info("link type: %lld", type); 953 debug_info("link type: %lld", type);
@@ -974,14 +974,14 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c
974 974
975afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) 975afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime)
976{ 976{
977 if (!client || !path || !client->afc_packet || !client->parent)
978 return AFC_E_INVALID_ARG;
979
977 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); 980 char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
978 uint32_t bytes = 0; 981 uint32_t bytes = 0;
979 uint64_t mtime_loc = htole64(mtime); 982 uint64_t mtime_loc = htole64(mtime);
980 afc_error_t ret = AFC_E_UNKNOWN_ERROR; 983 afc_error_t ret = AFC_E_UNKNOWN_ERROR;
981 984
982 if (!client || !path || !client->afc_packet || !client->parent)
983 return AFC_E_INVALID_ARG;
984
985 afc_lock(client); 985 afc_lock(client);
986 986
987 /* Send command */ 987 /* Send command */