From 01de5bc76a3e243b1b8df7f5d8961f02ee20d097 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 17 Mar 2018 13:22:41 +0100 Subject: [PATCH] Add extra check for path traversal sanity. --- chrome/nsChromeRegistry.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 0aa7f3f149..e88aca41f2 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -238,6 +238,12 @@ nsChromeRegistry::Canonify(nsIURL* aChromeURL) // path is already unescaped once, but uris can get unescaped twice const char* pos = path.BeginReading(); const char* end = path.EndReading(); + // Must start with [a-zA-Z0-9]. + if (!('a' <= *pos && *pos <= 'z') && + !('A' <= *pos && *pos <= 'Z') && + !('0' <= *pos && *pos <= '9')) { + return NS_ERROR_DOM_BAD_URI; + } while (pos < end) { switch (*pos) { case ':':