diff --git a/src/cookies/path.c b/src/cookies/path.c index c7516b93..406d3d26 100644 --- a/src/cookies/path.c +++ b/src/cookies/path.c @@ -6,15 +6,9 @@ int is_path_prefix(unsigned char *cookiepath, unsigned char *requestpath) { int dl = strlen(cookiepath); - int sl = strlen(requestpath); - - if (dl > sl) return 0; if (memcmp(cookiepath, requestpath, dl)) return 0; - if (dl == sl) return 1; - - if (cookiepath[dl - 1] == '/') return 1; - - return (requestpath[dl] == '/'); + return (!memcmp(cookiepath, requestpath, dl) + && (cookiepath[dl - 1] == '/' || requestpath[dl] == '/' || requestpath[dl] == '\0')); }