scheduler: fix bug in copying long XML elements

This commit is contained in:
David Anderson 2013-05-08 15:34:37 -07:00
parent 8e566a62fc
commit 4927acf25a
1 changed files with 6 additions and 2 deletions

View File

@ -214,14 +214,18 @@ int dup_element(FILE* in, const char* tag_name, char** pp) {
int copy_element_contents(FILE* in, const char* end_tag, char* p, int len) { int copy_element_contents(FILE* in, const char* end_tag, char* p, int len) {
char buf[256]; char buf[256];
int n; int n;
int retval = 0;
strcpy(p, ""); strcpy(p, "");
while (fgets(buf, 256, in)) { while (fgets(buf, 256, in)) {
if (strstr(buf, end_tag)) { if (strstr(buf, end_tag)) {
return 0; return retval;
} }
n = (int)strlen(buf); n = (int)strlen(buf);
if (n >= len-1) return ERR_XML_PARSE; if (n >= len-1) {
retval = ERR_XML_PARSE;
continue;
}
strcat(p, buf); strcat(p, buf);
len -= n; len -= n;
} }