soc.2012.statscollector: 02775aef: [BUG] NULL terminate the rand_md5 string

sanket at soc.pidgin.im sanket at soc.pidgin.im
Sat Jun 2 06:47:14 EDT 2012


----------------------------------------------------------------------
Revision: 02775aef0547d2b5a0d920a3f59f1f47ab6309f9
Parent:   3ff37c9c0bfc4876905e342fc23b4a0448dade77
Author:   sanket at soc.pidgin.im
Date:     06/02/12 07:39:56
Branch:   im.pidgin.soc.2012.statscollector
URL: http://d.pidgin.im/viewmtn/revision/info/02775aef0547d2b5a0d920a3f59f1f47ab6309f9

Changelog: 

[BUG] NULL terminate the rand_md5 string

There is a bug that rand_md5 string is *not* NULL terminated, and hence
it picks up data after the string which makes the HASH inconsistent while
printing. Simply, NULL terminate the string to that purpose.

Changes against parent 3ff37c9c0bfc4876905e342fc23b4a0448dade77

  patched  libpurple/plugins/statscollector.c

-------------- next part --------------
============================================================
--- libpurple/plugins/statscollector.c	f9d65a198aed914f2c5c97cf9f0f3ce81b542cdf
+++ libpurple/plugins/statscollector.c	c28b5e1c8a79b94b27c7f70f5c87360c6b7c51d8
@@ -80,7 +80,7 @@ rand_md5(){
   g_get_current_time(&time);
 
   /* Creates a random MD5 (16bytes) string */
-  rand_str = (char *)g_new0(char, 16*2);
+  rand_str = (char *)g_new0(char, 16*2+1);
 
   /* Initialize the seed */
   srand(time.tv_sec * time.tv_usec);
@@ -90,6 +90,8 @@ rand_md5(){
     rand_str[i] = e[rand()%16];
   }
 
+  rand_str[i] = '\0';
+
   return rand_str;
 
 }


More information about the Commits mailing list