--- a/src/mesa/drivers/dri/common/xmlconfig.c.orig 2015-02-06 16:09:52.000000000 -0800
+++ a/src/mesa/drivers/dri/common/xmlconfig.c 2015-02-11 11:32:32.000000000 -0800
@@ -105,6 +105,24 @@ static const char *__getProgramName () {
+#define strndup __xmlconfig_strndup
+strndup(const char *str, size_t n)
+ for (len = 0; len < n && str[len]; len++)
+ if ((copy = (char *)malloc(len + 1)) == NULL)
+ memcpy(copy, str, len);
/** \brief Find an option in an option cache with the name as key */
static uint32_t findOption (const driOptionCache *cache, const char *name) {
uint32_t len = strlen (name);
--- a/src/util/ralloc.c 2015-12-28 00:25:30.000000000 -0800
+++ b/src/util/ralloc.c 2015-12-28 00:26:50.000000000 -0800
@@ -353,17 +353,17 @@ ralloc_strdup(const void *ctx, const cha
ralloc_strndup(const void *ctx, const char *str, size_t max)
if (unlikely(str == NULL))
+ for (n = 0; n < max && str[n]; n++);
ptr = ralloc_array(ctx, char, n + 1);
/* helper routine for strcat/strncat - n is the exact amount to copy */
--- a/src/compiler/glsl/linker.cpp.orig 2016-05-08 16:23:12.000000000 -0700
+++ a/src/compiler/glsl/linker.cpp 2016-05-08 16:28:12.000000000 -0700
} /* anonymous namespace */
+#define strndup __linker_strndup
+strndup(const char *str, size_t n)