Mercurial > pidgin-twitter
changeset 311:5a22c65d019c
fix for memory overrun
author | Yoshiki Yazawa <[email protected]> |
---|---|
date | Sun, 05 Jul 2009 10:40:27 +0900 |
parents | aa1f0dd1a723 |
children | e2156468f4e5 |
files | util.c |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util.c Thu Jul 02 15:54:44 2009 +0900 +++ b/util.c Sun Jul 05 10:40:27 2009 +0900 @@ -77,10 +77,12 @@ const gchar *ptr, *ent; gchar *ptr2; + gint srclen; gint entlen; /* unescape &x; */ - html = g_malloc0(strlen(src) + 1); + srclen = strlen(src); + html = g_malloc0(srclen + 1); ptr2 = html; for(ptr = src; *ptr; ) { if(*ptr == '&') { @@ -98,6 +100,8 @@ else { *ptr2++ = *ptr++; } + if(ptr2 - html > srclen) + break; } /* for */ str = g_strdup("\0");