-fixes
[oweals/gnunet.git] / src / util / crypto_hash.c
index 0350df5454fc95c6631631edba7a29a2c6594e6e..f896390455bfd5321c0fa89fcdd79ff1524a0e6b 100644 (file)
@@ -241,9 +241,10 @@ GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc)
 }
 
 
-
 /* ***************** binary-ASCII encoding *************** */
 
+/* FIXME: should use GNUNET_STRINGS_data_to_string and strings_to_data below!!! */
+
 /**
  * Get the numeric value corresponding to a character.
  *
@@ -318,11 +319,13 @@ GNUNET_CRYPTO_hash_to_enc (const GNUNET_HashCode * block,
  * Convert ASCII encoding back to GNUNET_CRYPTO_hash
  *
  * @param enc the encoding
+ * @param enclen number of characters in 'enc' (without 0-terminator, which can be missing)
  * @param result where to store the GNUNET_CRYPTO_hash code
  * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
  */
 int
-GNUNET_CRYPTO_hash_from_string (const char *enc, GNUNET_HashCode * result)
+GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
+                                GNUNET_HashCode * result)
 {
   unsigned int rpos;
   unsigned int wpos;
@@ -330,7 +333,7 @@ GNUNET_CRYPTO_hash_from_string (const char *enc, GNUNET_HashCode * result)
   unsigned int vbit;
   int ret;
 
-  if (strlen (enc) != sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1)
+  if (enclen != sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1)
     return GNUNET_SYSERR;
 
   vbit = 2;                     /* padding! */