summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2009-11-01 22:09:43 +0100
committerGravatar Matt Colyer2009-11-05 20:45:40 -0800
commit8e489a46965bbc3683cec7698ccaf71bb5855d2a (patch)
tree996dd38f16881a46ce8a5be20b57375f731fe18c /src
parent549f4389e3009d9f78b94d4a3570e29f428968ab (diff)
downloadlibimobiledevice-8e489a46965bbc3683cec7698ccaf71bb5855d2a.tar.gz
libimobiledevice-8e489a46965bbc3683cec7698ccaf71bb5855d2a.tar.bz2
make sure 'length' is >=0 in afc_file_write
trying to write a negative amount of data doesn't make much sense, and bad things will happen if we try to do that. Just treat negative length values as an invalid argument. An alternative way of handling it would be to silently return OK/0 bytes written.
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 54b3795..c97141c 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -819,7 +819,7 @@ afc_file_write(afc_client_t client, uint64_t handle,
char *out_buffer = NULL;
afc_error_t ret = AFC_E_SUCCESS;
- if (!client || !client->afc_packet || !client->connection || !bytes || (handle == 0))
+ if (!client || !client->afc_packet || !client->connection || !bytes || (handle == 0) || (length < 0))
return AFC_E_INVALID_ARGUMENT;
afc_lock(client);