[libxml2] Annotate functions with __attribute__((no_sanitize))



commit 44e7a0d5f7a7e2c167a8a4196a5358830f695ab0
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu May 16 21:17:28 2019 +0200

    Annotate functions with __attribute__((no_sanitize))

 dict.c   | 2 ++
 hash.c   | 2 ++
 libxml.h | 7 +++++++
 xpath.c  | 1 +
 4 files changed, 12 insertions(+)
---
diff --git a/dict.c b/dict.c
index 14fe398e..13a7b937 100644
--- a/dict.c
+++ b/dict.c
@@ -372,6 +372,7 @@ found_pool:
  * http://burtleburtle.net/bob/hash/doobs.html
  */
 
+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
 static uint32_t
 xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
     uint32_t hash;
@@ -404,6 +405,7 @@ xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
  *
  * Neither of the two strings must be NULL.
  */
+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
 static unsigned long
 xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
                       const xmlChar *name, int len, int seed)
diff --git a/hash.c b/hash.c
index 1145cb93..f037af69 100644
--- a/hash.c
+++ b/hash.c
@@ -79,6 +79,7 @@ struct _xmlHashTable {
  * xmlHashComputeKey:
  * Calculate the hash key
  */
+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
 static unsigned long
 xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
                  const xmlChar *name2, const xmlChar *name3) {
@@ -109,6 +110,7 @@ xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
     return (value % table->size);
 }
 
+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
 static unsigned long
 xmlHashComputeQKey(xmlHashTablePtr table,
                   const xmlChar *prefix, const xmlChar *name,
diff --git a/libxml.h b/libxml.h
index 64e30f77..77623310 100644
--- a/libxml.h
+++ b/libxml.h
@@ -72,6 +72,13 @@ int vfprintf(FILE *, const char *, va_list);
 #define XML_POP_WARNINGS
 #endif
 
+#if defined(__clang__) || \
+    (defined(__GNUC__) && (__GNUC__ >= 8))
+#define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))
+#else
+#define ATTRIBUTE_NO_SANITIZE(arg)
+#endif
+
 /*
  * Internal variable indicating if a callback has been registered for
  * node creation/destruction. It avoids spending a lot of time in locking
diff --git a/xpath.c b/xpath.c
index 031772ce..e68975ef 100644
--- a/xpath.c
+++ b/xpath.c
@@ -7497,6 +7497,7 @@ xmlXPathMultValues(xmlXPathParserContextPtr ctxt) {
  * The numeric operators convert their operands to numbers as if
  * by calling the number function.
  */
+ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
 void
 xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
     xmlXPathObjectPtr arg;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]