+2010-03-31 Keith Marshall <keithmarshall@users.sourceforge.net>
+
+ Guard against NULL pointer dereferences in tinyxml code.
+
+ * src/pkgbase.h (pkgXmlNode::GetName): Verify `this' pointer is
+ non-NULL, before invoking the underlying tinyxml method.
+ (pkgXmlNode::GetParent, pkgXmlNode::GetChildren): Likewise.
+ (pkgXmlNode::GetNext, pkgXmlNode::GetPropVal): Likewise.
+ (pkgXmlNode::AddChild, pkgXmlNode::DeleteChild): Likewise.
+ (pkgXmlNode::GetDocumentRoot): Likewise.
+ (pkgXmlNode::IsElementOfType): Likewise.
+
2010-03-28 Cesar Strauss <cestrauss@gmail.com>
Avoid running InternetAttemptConnect in pkgInternetAgent
inline pkgXmlNode( const pkgXmlNode& src ):TiXmlElement( src ){}
/* 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()
{
/* Retrieve the identifying name of the XML tag;
* tinyxml calls this the element "value"...
*/
- return Value();
+ return this ? Value() : NULL;
}
inline pkgXmlNode* GetParent()
{
/* wxXmlNode provides this equivalant of tinyxml's
* Parent() method.
*/
- return (pkgXmlNode*)(Parent());
+ return this ? (pkgXmlNode*)(Parent()) : NULL;
}
inline pkgXmlNode* GetChildren()
{
* the children of an element; it is equivalent to the
* FirstChild() method in tinyxml's arsenal.
*/
- return (pkgXmlNode*)(FirstChild());
+ return this ? (pkgXmlNode*)(FirstChild()) : NULL;
}
inline pkgXmlNode* GetNext()
{
* of an element, after the first found by GetChildren();
* it is equivalent to tinyxml's NextSibling().
*/
- return (pkgXmlNode*)(NextSibling());
+ return this ? (pkgXmlNode*)(NextSibling()) : NULL;
}
inline const char* GetPropVal( const char* name, const char* subst )
{
* (which substitutes default "subst" text for an omitted property),
* but it may be trivially emulated, using the Attribute() method.
*/
- const char* retval = Attribute( name );
+ const char* retval = this ? Attribute( name ) : subst;
return retval ? retval : subst;
}
inline pkgXmlNode* AddChild( TiXmlNode *child )
/* This is wxXmlNode's method for adding a child node, it is
* equivalent to tinyxml's LinkEndChild() method.
*/
- return (pkgXmlNode*)(LinkEndChild( child ));
+ return this ? (pkgXmlNode*)(LinkEndChild( child )) : NULL;
}
inline bool DeleteChild( pkgXmlNode *child )
{
* simply use the RemoveChild method here, where for wxXmlNode, we
* would use RemoveChild followed by `delete child'.
*/
- return RemoveChild( child );
+ return this ? RemoveChild( child ) : false;
}
/* Additional methods specific to the application.
{
/* Convenience method to retrieve a pointer to the document root.
*/
- return (pkgXmlNode*)(GetDocument()->RootElement());
+ return this ? (pkgXmlNode*)(GetDocument()->RootElement()) : NULL;
}
inline bool IsElementOfType( const char* tagname )
{
/* Confirm if the owner XML node represents a data element
* with the specified "tagname".
*/
- return strcmp( GetName(), tagname ) == 0;
+ return this ? strcmp( GetName(), tagname ) == 0 : false;
}
/* Methods for retrieving the system root management records
};
enum { to_remove = 0, to_install, selection_types };
+
class pkgActionItem
{
/* A class implementing a bi-directionally linked list of