gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34696 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r34696 - gnunet/src/util
Date: Fri, 19 Dec 2014 21:16:10 +0100

Author: amatus
Date: 2014-12-19 21:16:10 +0100 (Fri, 19 Dec 2014)
New Revision: 34696

Modified:
   gnunet/src/util/strings.c
Log:
Fix 'STRINGS_data_to_string size check and comment


Modified: gnunet/src/util/strings.c
===================================================================
--- gnunet/src/util/strings.c   2014-12-19 14:16:54 UTC (rev 34695)
+++ gnunet/src/util/strings.c   2014-12-19 20:16:10 UTC (rev 34696)
@@ -838,14 +838,14 @@
 
 /**
  * Convert binary data to ASCII encoding using Crockford Base32 encoding.
- * Does not append 0-terminator, but returns a pointer to the place where
- * it should be placed, if needed.
+ * Returns a pointer to the byte after the last byte in the string, that
+ * is where the 0-terminator was placed if there was room.
  *
  * @param data data to encode
  * @param size size of data (in bytes)
  * @param out buffer to fill
  * @param out_size size of the buffer. Must be large enough to hold
- * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 bytes
+ * (size * 8 + 4) / 5 bytes
  * @return pointer to the next byte in 'out' or NULL on error.
  */
 char *
@@ -864,7 +864,7 @@
   GNUNET_assert (data != NULL);
   GNUNET_assert (out != NULL);
   udata = data;
-  if (out_size < (((size*8) + ((size*8) % 5)) % 5))
+  if (out_size < (size * 8 + 4) / 5)
   {
     GNUNET_break (0);
     return NULL;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]