Ticket #54356: patch-lib-xmlparse.c.diff
File patch-lib-xmlparse.c.diff, 5.1 KB (added by Schamschula (Marius Schamschula), 7 years ago) |
---|
-
lib/xmlparse.c
old new 623 623 #define defaultExpandInternalEntities \ 624 624 (parser->m_defaultExpandInternalEntities) 625 625 #define tagLevel (parser->m_tagLevel) 626 #define buffer (parser->m_buffer)626 #define xbuffer (parser->m_buffer) 627 627 #define bufferPtr (parser->m_bufferPtr) 628 628 #define bufferEnd (parser->m_bufferEnd) 629 629 #define parseEndByteIndex (parser->m_parseEndByteIndex) … … 901 901 if (!parser) 902 902 return parser; 903 903 904 buffer = NULL;904 xbuffer = NULL; 905 905 bufferLim = NULL; 906 906 907 907 attsSize = INIT_ATTS_SIZE; … … 1017 1017 attlistDeclHandler = NULL; 1018 1018 entityDeclHandler = NULL; 1019 1019 xmlDeclHandler = NULL; 1020 bufferPtr = buffer;1021 bufferEnd = buffer;1020 bufferPtr = xbuffer; 1021 bufferEnd = xbuffer; 1022 1022 parseEndByteIndex = 0; 1023 1023 parseEndPtr = NULL; 1024 1024 declElementType = NULL; … … 1371 1371 FREE((void *)attInfo); 1372 1372 #endif 1373 1373 FREE(groupConnector); 1374 FREE( buffer);1374 FREE(xbuffer); 1375 1375 FREE(dataBuf); 1376 1376 FREE(nsAtts); 1377 1377 FREE(unknownEncodingMem); … … 1841 1841 XmlUpdatePosition(encoding, positionPtr, end, &position); 1842 1842 nLeftOver = s + len - end; 1843 1843 if (nLeftOver) { 1844 if ( buffer == NULL || nLeftOver > bufferLim -buffer) {1844 if (xbuffer == NULL || nLeftOver > bufferLim - xbuffer) { 1845 1845 /* avoid _signed_ integer overflow */ 1846 1846 char *temp = NULL; 1847 1847 const int bytesToAllocate = (int)((unsigned)len * 2U); 1848 1848 if (bytesToAllocate > 0) { 1849 temp = ( buffer == NULL1849 temp = (xbuffer == NULL 1850 1850 ? (char *)MALLOC(bytesToAllocate) 1851 : (char *)REALLOC( buffer, bytesToAllocate));1851 : (char *)REALLOC(xbuffer, bytesToAllocate)); 1852 1852 } 1853 1853 if (temp == NULL) { 1854 1854 errorCode = XML_ERROR_NO_MEMORY; … … 1856 1856 processor = errorProcessor; 1857 1857 return XML_STATUS_ERROR; 1858 1858 } 1859 buffer = temp;1860 bufferLim = buffer + bytesToAllocate;1859 xbuffer = temp; 1860 bufferLim = xbuffer + bytesToAllocate; 1861 1861 } 1862 memcpy( buffer, end, nLeftOver);1862 memcpy(xbuffer, end, nLeftOver); 1863 1863 } 1864 bufferPtr = buffer;1865 bufferEnd = buffer + nLeftOver;1864 bufferPtr = xbuffer; 1865 bufferEnd = xbuffer + nLeftOver; 1866 1866 positionPtr = bufferPtr; 1867 1867 parseEndPtr = bufferEnd; 1868 1868 eventPtr = bufferPtr; … … 1969 1969 return NULL; 1970 1970 } 1971 1971 #ifdef XML_CONTEXT_BYTES 1972 keep = (int)(bufferPtr - buffer);1972 keep = (int)(bufferPtr - xbuffer); 1973 1973 if (keep > XML_CONTEXT_BYTES) 1974 1974 keep = XML_CONTEXT_BYTES; 1975 1975 neededSize += keep; 1976 1976 #endif /* defined XML_CONTEXT_BYTES */ 1977 if (neededSize <= bufferLim - buffer) {1977 if (neededSize <= bufferLim - xbuffer) { 1978 1978 #ifdef XML_CONTEXT_BYTES 1979 if (keep < bufferPtr - buffer) {1980 int offset = (int)(bufferPtr - buffer) - keep;1981 memmove( buffer, &buffer[offset], bufferEnd - bufferPtr + keep);1979 if (keep < bufferPtr - xbuffer) { 1980 int offset = (int)(bufferPtr - xbuffer) - keep; 1981 memmove(xbuffer, &xbuffer[offset], bufferEnd - bufferPtr + keep); 1982 1982 bufferEnd -= offset; 1983 1983 bufferPtr -= offset; 1984 1984 } 1985 1985 #else 1986 memmove( buffer, bufferPtr, bufferEnd - bufferPtr);1987 bufferEnd = buffer + (bufferEnd - bufferPtr);1988 bufferPtr = buffer;1986 memmove(xbuffer, bufferPtr, bufferEnd - bufferPtr); 1987 bufferEnd = xbuffer + (bufferEnd - bufferPtr); 1988 bufferPtr = xbuffer; 1989 1989 #endif /* not defined XML_CONTEXT_BYTES */ 1990 1990 } 1991 1991 else { … … 2009 2009 bufferLim = newBuf + bufferSize; 2010 2010 #ifdef XML_CONTEXT_BYTES 2011 2011 if (bufferPtr) { 2012 int keep = (int)(bufferPtr - buffer);2012 int keep = (int)(bufferPtr - xbuffer); 2013 2013 if (keep > XML_CONTEXT_BYTES) 2014 2014 keep = XML_CONTEXT_BYTES; 2015 2015 memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); 2016 FREE( buffer);2017 buffer = newBuf;2018 bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;2019 bufferPtr = buffer + keep;2016 FREE(xbuffer); 2017 xbuffer = newBuf; 2018 bufferEnd = xbuffer + (bufferEnd - bufferPtr) + keep; 2019 bufferPtr = xbuffer + keep; 2020 2020 } 2021 2021 else { 2022 2022 bufferEnd = newBuf + (bufferEnd - bufferPtr); 2023 bufferPtr = buffer = newBuf;2023 bufferPtr = xbuffer = newBuf; 2024 2024 } 2025 2025 #else 2026 2026 if (bufferPtr) { 2027 2027 memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); 2028 FREE( buffer);2028 FREE(xbuffer); 2029 2029 } 2030 2030 bufferEnd = newBuf + (bufferEnd - bufferPtr); 2031 bufferPtr = buffer = newBuf;2031 bufferPtr = xbuffer = newBuf; 2032 2032 #endif /* not defined XML_CONTEXT_BYTES */ 2033 2033 } 2034 2034 eventPtr = eventEndPtr = NULL; … … 2152 2152 #ifdef XML_CONTEXT_BYTES 2153 2153 if (parser == NULL) 2154 2154 return NULL; 2155 if (eventPtr && buffer) {2155 if (eventPtr && xbuffer) { 2156 2156 if (offset != NULL) 2157 *offset = (int)(eventPtr - buffer);2157 *offset = (int)(eventPtr - xbuffer); 2158 2158 if (size != NULL) 2159 *size = (int)(bufferEnd - buffer);2160 return buffer;2159 *size = (int)(bufferEnd - xbuffer); 2160 return xbuffer; 2161 2161 } 2162 2162 #else 2163 2163 (void)parser;