summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-03-31 11:43:39 +0200
committerGravatar Martin Szulecki2012-03-22 18:47:27 +0100
commit1e13d7d1420ba8353d8056a5dccaa76cbd3f9ac5 (patch)
tree68f8e00ccf83af3817896f9a098489c0ca91eaa6
parent489cdad395a0518392c504a99fff01cf112b2c0d (diff)
downloadlibimobiledevice-1e13d7d1420ba8353d8056a5dccaa76cbd3f9ac5.tar.gz
libimobiledevice-1e13d7d1420ba8353d8056a5dccaa76cbd3f9ac5.tar.bz2
userpref: Fix a segfault that might occour if locally stored certs could not be read
userpref_get_file_contents() was stil attempting to set the data and size properties on the passed gnutls_datum_t even if g_file_get_contents() failed. This shoud fix a possible segfault in any code code using the pairing.
-rw-r--r--src/userpref.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/userpref.c b/src/userpref.c
index 6e62000..4aab67b 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -328,8 +328,10 @@ static int userpref_get_file_contents(const char *file, gnutls_datum_t * data)
g_free(filepath);
/* Add it to the gnutls_datnum_t structure */
- data->data = (uint8_t*) content;
- data->size = size;
+ if (success) {
+ data->data = (uint8_t*) content;
+ data->size = size;
+ }
return success;
}