summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-12-12 13:44:06 -0800
committerEric Anholt <eric@anholt.net>2013-12-12 17:17:17 -0800
commit03e9537331269442e0c2c3a59fe0b325cc4770a0 (patch)
treec28b74fd0678acf868ec177263087cd086d9154d
parentcb647a085398e2d6dd063aabde626b758f3ab307 (diff)
Fix infinite loop in extension detection when the needle is a substring.
We could keep examining the same ptr value over and over.
-rw-r--r--src/dispatch_common.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index b8b9184..8d7c1d1 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -265,11 +265,15 @@ epoxy_extension_in_string(const char *extension_list, const char *ext)
int len = strlen(ext);
/* Make sure that don't just find an extension with our name as a prefix. */
- do {
+ while (true) {
ptr = strstr(ptr, ext);
- } while (ptr && (ptr[len] != ' ' && ptr[len] != 0));
+ if (!ptr)
+ return false;
- return ptr != NULL;
+ if (ptr[len] == ' ' || ptr[len] == 0)
+ return true;
+ ptr += len;
+ }
}
static bool