30 lines
906 B
Diff
30 lines
906 B
Diff
From c6ae07c6a541e0e96d0040afb62b45dd37711300 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Stenberg <daniel@haxx.se>
|
|
Date: Mon, 11 Aug 2025 20:23:05 +0200
|
|
Subject: [PATCH] cookie: don't treat the leading slash as trailing
|
|
|
|
If there is only a leading slash in the path, keep that. Also add an
|
|
assert to make sure the path is never blank.
|
|
|
|
Reported-by: Google Big Sleep
|
|
Closes #18266
|
|
---
|
|
lib/cookie.c | 11 ++++++-----
|
|
1 file changed, 6 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/lib/cookie.c b/lib/cookie.c
|
|
index 914a4aca12ac..b72dd99bce9b 100644
|
|
--- a/lib/cookie.c
|
|
+++ b/lib/cookie.c
|
|
@@ -420,8 +420,9 @@ static char *sanitize_cookie_path(const char *cookie_path)
|
|
return new_path;
|
|
}
|
|
|
|
+ /* remove trailing slash when path is non-empty (len > 1) */
|
|
/* convert /hoge/ to /hoge */
|
|
- if(len && new_path[len - 1] == '/') {
|
|
+ if(len > 1 && new_path[len - 1] == '/') {
|
|
new_path[len - 1] = 0x0;
|
|
}
|
|
|