From 115d26608bd059653a69b569253a352ad1427a97 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 26 Dec 2009 02:19:56 +0100 Subject: uri: check presence of slash in suffix If there's a slash in the uri_get_suffix() return value, then it's malformed. Return NULL in this case. --- src/uri.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/uri.c') diff --git a/src/uri.c b/src/uri.c index 5c33d3ba..41a613de 100644 --- a/src/uri.c +++ b/src/uri.c @@ -33,9 +33,16 @@ bool uri_has_scheme(const char *uri) const char * uri_get_suffix(const char *uri) { - const char *dot = strrchr(g_basename(uri), '.'); + const char *suffix = strrchr(g_basename(uri), '.'); + if (suffix == NULL) + return NULL; + + ++suffix; + + if (strchr(suffix, '/') != NULL) + return NULL; - return dot != NULL ? dot + 1 : NULL; + return suffix; } char * -- cgit v1.2.3