Added some checks and allow -1 as buffer_size.

This commit is contained in:
Sven Neumann 2002-02-11 22:58:44 +00:00
parent 2c2ca836fd
commit 64f76a9b80
1 changed files with 7 additions and 1 deletions

View File

@ -52,7 +52,7 @@ static void gimp_md5_final (GimpMD5Context *ctx,
/**
* gimp_md5_get_digest:
* @buffer: byte buffer
* @buffer_size: buffer size (in bytes)
* @buffer_size: buffer size (in bytes) or -1 if @buffer is nul-terminated.
* @digest: 16 bytes buffer receiving the hash code.
*
* Get the md5 hash of a buffer. The result is put in the 16 bytes
@ -72,6 +72,12 @@ gimp_md5_get_digest (const gchar *buffer,
{
GimpMD5Context ctx;
g_return_if_fail (buffer != NULL);
g_return_if_fail (digest != NULL);
if (buffer_size < 0)
buffer_size = strlen (buffer);
gimp_md5_init (&ctx);
gimp_md5_update (&ctx, buffer, buffer_size);
gimp_md5_final (&ctx, digest);