From: Keith M. <kei...@us...> - 2010-04-02 08:38:12
|
Update of /cvsroot/mingw/mingw-get/src In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv6793/src Modified Files: pkgbase.h Log Message: Guard against NULL pointer dereferences in tinyxml code. Index: pkgbase.h =================================================================== RCS file: /cvsroot/mingw/mingw-get/src/pkgbase.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pkgbase.h 22 Mar 2010 19:39:06 -0000 1.6 --- pkgbase.h 2 Apr 2010 08:38:04 -0000 1.7 *************** *** 85,88 **** --- 85,92 ---- /* Accessors... + * + * Note that tinyxml is generally careless about checking for + * possible dereferencing of NULL pointers; thus, many of these + * wrappers include appropriate checks, to prevent this. */ inline const char* GetName() *************** *** 91,95 **** * tinyxml calls this the element "value"... */ ! return Value(); } inline pkgXmlNode* GetParent() --- 95,99 ---- * tinyxml calls this the element "value"... */ ! return this ? Value() : NULL; } inline pkgXmlNode* GetParent() *************** *** 98,102 **** * Parent() method. */ ! return (pkgXmlNode*)(Parent()); } inline pkgXmlNode* GetChildren() --- 102,106 ---- * Parent() method. */ ! return this ? (pkgXmlNode*)(Parent()) : NULL; } inline pkgXmlNode* GetChildren() *************** *** 106,110 **** * FirstChild() method in tinyxml's arsenal. */ ! return (pkgXmlNode*)(FirstChild()); } inline pkgXmlNode* GetNext() --- 110,114 ---- * FirstChild() method in tinyxml's arsenal. */ ! return this ? (pkgXmlNode*)(FirstChild()) : NULL; } inline pkgXmlNode* GetNext() *************** *** 114,118 **** * it is equivalent to tinyxml's NextSibling(). */ ! return (pkgXmlNode*)(NextSibling()); } inline const char* GetPropVal( const char* name, const char* subst ) --- 118,122 ---- * it is equivalent to tinyxml's NextSibling(). */ ! return this ? (pkgXmlNode*)(NextSibling()) : NULL; } inline const char* GetPropVal( const char* name, const char* subst ) *************** *** 122,126 **** * but it may be trivially emulated, using the Attribute() method. */ ! const char* retval = Attribute( name ); return retval ? retval : subst; } --- 126,130 ---- * but it may be trivially emulated, using the Attribute() method. */ ! const char* retval = this ? Attribute( name ) : subst; return retval ? retval : subst; } *************** *** 130,134 **** * equivalent to tinyxml's LinkEndChild() method. */ ! return (pkgXmlNode*)(LinkEndChild( child )); } inline bool DeleteChild( pkgXmlNode *child ) --- 134,138 ---- * equivalent to tinyxml's LinkEndChild() method. */ ! return this ? (pkgXmlNode*)(LinkEndChild( child )) : NULL; } inline bool DeleteChild( pkgXmlNode *child ) *************** *** 139,143 **** * would use RemoveChild followed by `delete child'. */ ! return RemoveChild( child ); } --- 143,147 ---- * would use RemoveChild followed by `delete child'. */ ! return this ? RemoveChild( child ) : false; } *************** *** 148,152 **** /* Convenience method to retrieve a pointer to the document root. */ ! return (pkgXmlNode*)(GetDocument()->RootElement()); } inline bool IsElementOfType( const char* tagname ) --- 152,156 ---- /* Convenience method to retrieve a pointer to the document root. */ ! return this ? (pkgXmlNode*)(GetDocument()->RootElement()) : NULL; } inline bool IsElementOfType( const char* tagname ) *************** *** 155,159 **** * with the specified "tagname". */ ! return strcmp( GetName(), tagname ) == 0; } --- 159,163 ---- * with the specified "tagname". */ ! return this ? strcmp( GetName(), tagname ) == 0 : false; } *************** *** 181,184 **** --- 185,189 ---- enum { to_remove = 0, to_install, selection_types }; + class pkgActionItem { |