diff options
author | Aaron Burghardt | 2014-08-24 21:17:47 -0400 |
---|---|---|
committer | Aaron Burghardt | 2014-08-25 06:01:43 -0400 |
commit | 5fecc039a7660aabe27304e3479f5ff4c7fd4bab (patch) | |
tree | 03d43dc34e55cdade9ccecdeee0b0eca83ca3e47 | |
parent | 8e96f2af5960f4f5e4b52e4d7fe4e3c0ff2fe655 (diff) | |
download | libimobiledevice-5fecc039a7660aabe27304e3479f5ff4c7fd4bab.tar.gz libimobiledevice-5fecc039a7660aabe27304e3479f5ff4c7fd4bab.tar.bz2 |
afc.c: fixed leaks in various functions when an invalid argument error is returned.
-rw-r--r-- | src/afc.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -531,13 +531,13 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path) afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to) { + if (!client || !from || !to || !client->afc_packet || !client->parent) + return AFC_E_INVALID_ARG; + char *buffer = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t))); uint32_t bytes = 0; afc_error_t ret = AFC_E_UNKNOWN_ERROR; - if (!client || !from || !to || !client->afc_packet || !client->parent) - return AFC_E_INVALID_ARG; - afc_lock(client); /* Send command */ @@ -910,14 +910,14 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize) { + if (!client || !path || !client->afc_packet || !client->parent) + return AFC_E_INVALID_ARG; + char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); uint32_t bytes = 0; uint64_t size_requested = htole64(newsize); afc_error_t ret = AFC_E_UNKNOWN_ERROR; - if (!client || !path || !client->afc_packet || !client->parent) - return AFC_E_INVALID_ARG; - afc_lock(client); /* Send command */ @@ -940,14 +940,14 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname) { + if (!client || !target || !linkname || !client->afc_packet || !client->parent) + return AFC_E_INVALID_ARG; + char *buffer = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); uint32_t bytes = 0; uint64_t type = htole64(linktype); afc_error_t ret = AFC_E_UNKNOWN_ERROR; - if (!client || !target || !linkname || !client->afc_packet || !client->parent) - return AFC_E_INVALID_ARG; - afc_lock(client); 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 afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime) { + if (!client || !path || !client->afc_packet || !client->parent) + return AFC_E_INVALID_ARG; + char *buffer = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); uint32_t bytes = 0; uint64_t mtime_loc = htole64(mtime); afc_error_t ret = AFC_E_UNKNOWN_ERROR; - if (!client || !path || !client->afc_packet || !client->parent) - return AFC_E_INVALID_ARG; - afc_lock(client); /* Send command */ |