mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
Merge pull request #1568 from lightpanda-io/invalid_cookie_samesite
protect against long invalid samesite cookie values
This commit is contained in:
@@ -83,7 +83,7 @@ pub fn parse(allocator: Allocator, url: [:0]const u8, str: []const u8) !Cookie {
|
|||||||
const sep = std.mem.indexOfScalarPos(u8, attribute, 0, '=') orelse attribute.len;
|
const sep = std.mem.indexOfScalarPos(u8, attribute, 0, '=') orelse attribute.len;
|
||||||
const key_string = trim(attribute[0..sep]);
|
const key_string = trim(attribute[0..sep]);
|
||||||
|
|
||||||
if (key_string.len > 8) {
|
if (key_string.len > scrap.len) {
|
||||||
// not valid, ignore
|
// not valid, ignore
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -107,6 +107,9 @@ pub fn parse(allocator: Allocator, url: [:0]const u8, str: []const u8) !Cookie {
|
|||||||
.expires => expires = value,
|
.expires => expires = value,
|
||||||
.httponly => http_only = true,
|
.httponly => http_only = true,
|
||||||
.samesite => {
|
.samesite => {
|
||||||
|
if (value.len > scrap.len) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
same_site = std.meta.stringToEnum(Cookie.SameSite, std.ascii.lowerString(&scrap, value)) orelse continue;
|
same_site = std.meta.stringToEnum(Cookie.SameSite, std.ascii.lowerString(&scrap, value)) orelse continue;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user