From 2ea15334a121b102f5b25c36357cbdb21d793ed8 Mon Sep 17 00:00:00 2001 From: Ryu Sawada Date: Tue, 22 May 2007 08:42:20 +0000 Subject: [PATCH] fixed a potential error by 'strcpy', which depends on libc implementation. --- mxml.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mxml.c b/mxml.c index 0fc1bdd..e132232 100755 --- a/mxml.c +++ b/mxml.c @@ -284,23 +284,27 @@ void mxml_decode(char *str) while ((p = strchr(p, '&')) != NULL) { if (strncmp(p, "<", 4) == 0) { *(p++) = '<'; - strcpy(p, p+3); + memmove(p, p+3, strlen(p+3) + 1); } else if (strncmp(p, ">", 4) == 0) { *(p++) = '>'; strcpy(p, p+3); + memmove(p, p+3, strlen(p+3) + 1); } else if (strncmp(p, "&", 5) == 0) { *(p++) = '&'; strcpy(p, p+4); + memmove(p, p+4, strlen(p+4) + 1); } else if (strncmp(p, """, 6) == 0) { *(p++) = '\"'; strcpy(p, p+5); + memmove(p, p+5, strlen(p+5) + 1); } else if (strncmp(p, "'", 6) == 0) { *(p++) = '\''; strcpy(p, p+5); + memmove(p, p+5, strlen(p+5) + 1); } else { p++; // skip unknown entity @@ -308,6 +312,7 @@ void mxml_decode(char *str) } /* if (str[0] == '\"' && str[strlen(str)-1] == '\"') { strcpy(str, str+1); + memmove(str, str+1, strlen(str+1) + 1); str[strlen(str)-1] = 0; }*/ }