mirror of
https://gitea.psi.ch/ELOG/mxml.git
synced 2026-09-09 01:23:22 +00:00
fixed a potential error by 'strcpy', which depends on libc implementation.
This commit is contained in:
parent
7947f08b0e
commit
2ea15334a1
7
mxml.c
7
mxml.c
@ -284,23 +284,27 @@ void mxml_decode(char *str)
|
|||||||
while ((p = strchr(p, '&')) != NULL) {
|
while ((p = strchr(p, '&')) != NULL) {
|
||||||
if (strncmp(p, "<", 4) == 0) {
|
if (strncmp(p, "<", 4) == 0) {
|
||||||
*(p++) = '<';
|
*(p++) = '<';
|
||||||
strcpy(p, p+3);
|
memmove(p, p+3, strlen(p+3) + 1);
|
||||||
}
|
}
|
||||||
else if (strncmp(p, ">", 4) == 0) {
|
else if (strncmp(p, ">", 4) == 0) {
|
||||||
*(p++) = '>';
|
*(p++) = '>';
|
||||||
strcpy(p, p+3);
|
strcpy(p, p+3);
|
||||||
|
memmove(p, p+3, strlen(p+3) + 1);
|
||||||
}
|
}
|
||||||
else if (strncmp(p, "&", 5) == 0) {
|
else if (strncmp(p, "&", 5) == 0) {
|
||||||
*(p++) = '&';
|
*(p++) = '&';
|
||||||
strcpy(p, p+4);
|
strcpy(p, p+4);
|
||||||
|
memmove(p, p+4, strlen(p+4) + 1);
|
||||||
}
|
}
|
||||||
else if (strncmp(p, """, 6) == 0) {
|
else if (strncmp(p, """, 6) == 0) {
|
||||||
*(p++) = '\"';
|
*(p++) = '\"';
|
||||||
strcpy(p, p+5);
|
strcpy(p, p+5);
|
||||||
|
memmove(p, p+5, strlen(p+5) + 1);
|
||||||
}
|
}
|
||||||
else if (strncmp(p, "'", 6) == 0) {
|
else if (strncmp(p, "'", 6) == 0) {
|
||||||
*(p++) = '\'';
|
*(p++) = '\'';
|
||||||
strcpy(p, p+5);
|
strcpy(p, p+5);
|
||||||
|
memmove(p, p+5, strlen(p+5) + 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p++; // skip unknown entity
|
p++; // skip unknown entity
|
||||||
@ -308,6 +312,7 @@ void mxml_decode(char *str)
|
|||||||
}
|
}
|
||||||
/* if (str[0] == '\"' && str[strlen(str)-1] == '\"') {
|
/* if (str[0] == '\"' && str[strlen(str)-1] == '\"') {
|
||||||
strcpy(str, str+1);
|
strcpy(str, str+1);
|
||||||
|
memmove(str, str+1, strlen(str+1) + 1);
|
||||||
str[strlen(str)-1] = 0;
|
str[strlen(str)-1] = 0;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user