From 8ba7176f81bc5533d26260cb676d9cd065da07c1 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 26 May 2020 20:47:31 +0200 Subject: [PATCH] [cookies] Slightly modified path.c --- src/cookies/path.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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')); }