ReactOS 0.4.16-dev-2132-g3885311
string.h File Reference
#include <libxml/xmlstring.h>
Include dependency graph for string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XML_HIDDEN xmlCharxmlEscapeFormatString (xmlChar **msg)
 

Function Documentation

◆ xmlEscapeFormatString()

XML_HIDDEN xmlChar * xmlEscapeFormatString ( xmlChar **  msg)

xmlEscapeFormatString: @msg: a pointer to the string in which to escape '' characters. Must be a heap-allocated buffer created by libxml2 that may be returned, or that may be freed and replaced.

Replaces the string pointed to by 'msg' with an escaped string. Returns the same string with all '' characters escaped.

Definition at line 1001 of file xmlstring.c.

1002{
1003 xmlChar *msgPtr = NULL;
1004 xmlChar *result = NULL;
1005 xmlChar *resultPtr = NULL;
1006 size_t count = 0;
1007 size_t msgLen = 0;
1008 size_t resultLen = 0;
1009
1010 if (!msg || !*msg)
1011 return(NULL);
1012
1013 for (msgPtr = *msg; *msgPtr != '\0'; ++msgPtr) {
1014 ++msgLen;
1015 if (*msgPtr == '%')
1016 ++count;
1017 }
1018
1019 if (count == 0)
1020 return(*msg);
1021
1022 if ((count > INT_MAX) || (msgLen > INT_MAX - count))
1023 return(NULL);
1024 resultLen = msgLen + count + 1;
1025 result = (xmlChar *) xmlMallocAtomic(resultLen);
1026 if (result == NULL) {
1027 /* Clear *msg to prevent format string vulnerabilities in
1028 out-of-memory situations. */
1029 xmlFree(*msg);
1030 *msg = NULL;
1031 return(NULL);
1032 }
1033
1034 for (msgPtr = *msg, resultPtr = result; *msgPtr != '\0'; ++msgPtr, ++resultPtr) {
1035 *resultPtr = *msgPtr;
1036 if (*msgPtr == '%')
1037 *(++resultPtr) = '%';
1038 }
1039 result[resultLen - 1] = '\0';
1040
1041 xmlFree(*msg);
1042 *msg = result;
1043
1044 return *msg;
1045}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
#define INT_MAX
Definition: limits.h:26
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
xmlFreeFunc xmlFree
Definition: globals.c:184
xmlMallocFunc xmlMallocAtomic
Definition: globals.c:204
unsigned char xmlChar
Definition: xmlstring.h:28