aboutsummaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2014-12-19 20:16:10 +0000
committerDavid Barksdale <amatus.amongus@gmail.com>2014-12-19 20:16:10 +0000
commita5e33f093cebc31423f085a816b3b297673c0baf (patch)
tree22bb96d15476899695478ccaed7b504768de5fde /src/util/strings.c
parent6963a2171087b9b7bb681f93b9795c8fa674c714 (diff)
downloadgnunet-a5e33f093cebc31423f085a816b3b297673c0baf.tar.gz
gnunet-a5e33f093cebc31423f085a816b3b297673c0baf.zip
Fix 'STRINGS_data_to_string size check and comment
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index 3dbcaf2c0..87c426b6c 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -838,14 +838,14 @@ getValue__ (unsigned char a)
838 838
839/** 839/**
840 * Convert binary data to ASCII encoding using Crockford Base32 encoding. 840 * Convert binary data to ASCII encoding using Crockford Base32 encoding.
841 * Does not append 0-terminator, but returns a pointer to the place where 841 * Returns a pointer to the byte after the last byte in the string, that
842 * it should be placed, if needed. 842 * is where the 0-terminator was placed if there was room.
843 * 843 *
844 * @param data data to encode 844 * @param data data to encode
845 * @param size size of data (in bytes) 845 * @param size size of data (in bytes)
846 * @param out buffer to fill 846 * @param out buffer to fill
847 * @param out_size size of the buffer. Must be large enough to hold 847 * @param out_size size of the buffer. Must be large enough to hold
848 * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 bytes 848 * (size * 8 + 4) / 5 bytes
849 * @return pointer to the next byte in 'out' or NULL on error. 849 * @return pointer to the next byte in 'out' or NULL on error.
850 */ 850 */
851char * 851char *
@@ -864,7 +864,7 @@ GNUNET_STRINGS_data_to_string (const void *data, size_t size, char *out, size_t
864 GNUNET_assert (data != NULL); 864 GNUNET_assert (data != NULL);
865 GNUNET_assert (out != NULL); 865 GNUNET_assert (out != NULL);
866 udata = data; 866 udata = data;
867 if (out_size < (((size*8) + ((size*8) % 5)) % 5)) 867 if (out_size < (size * 8 + 4) / 5)
868 { 868 {
869 GNUNET_break (0); 869 GNUNET_break (0);
870 return NULL; 870 return NULL;