Ticket #2217: seamonkey-1.1-location_hostname-1.patch

File seamonkey-1.1-location_hostname-1.patch, 2.8 KB (added by Ag. Hatzimanikas, 18 years ago)
  • TabularUnified netwerk/base/src/nsSimpleURI.cpp

    Submitted By: Hatzimanikas Agathoklis (a dot hatzim at gmail dot com)
    Date: 2007-02-25
    Initial Package Version: 1.1
    Origin: Upstream
    Upstream Status: Applied
    Description: Fixes security flaw.
                 https://bugzilla.mozilla.org/show_bug.cgi?id=370445
    
    diff -Naur mozilla.orig/netwerk/base/src/nsSimpleURI.cpp mozilla/netwerk/base/src/nsSimpleURI.cpp
    old new  
    155155    NS_EscapeURL(specPtr, specLen, esc_OnlyNonASCII|esc_AlwaysCopy, spec);
    156156
    157157    PRInt32 pos = spec.FindChar(':');
    158     if (pos == -1)
     158    if (pos == -1 || !net_IsValidScheme(spec.get(), pos))
    159159        return NS_ERROR_MALFORMED_URI;
    160160
    161161    mScheme.Truncate();
     
    182182NS_IMETHODIMP
    183183nsSimpleURI::SetScheme(const nsACString &scheme)
    184184{
     185    const nsPromiseFlatCString &flat = PromiseFlatCString(scheme);
     186    if (!net_IsValidScheme(flat)) {
     187        NS_ERROR("the given url scheme contains invalid characters");
     188        return NS_ERROR_MALFORMED_URI;
     189    }
     190
    185191    mScheme = scheme;
    186192    ToLowerCase(mScheme);
    187193    return NS_OK;
  • TabularUnified netwerk/base/src/nsStandardURL.cpp

    diff -Naur mozilla.orig/netwerk/base/src/nsStandardURL.cpp mozilla/netwerk/base/src/nsStandardURL.cpp
    old new  
    504504    if (mHost.mLen > 0) {
    505505        const nsCSubstring& tempHost =
    506506            Substring(spec + mHost.mPos, spec + mHost.mPos + mHost.mLen);
     507        if (tempHost.FindChar('\0') != kNotFound)
     508            return NS_ERROR_MALFORMED_URI;  // null embedded in hostname
    507509        if ((useEncHost = NormalizeIDN(tempHost, encHost)))
    508510            approxLen += encHost.Length();
    509511        else
     
    14081410        return NS_ERROR_UNEXPECTED;
    14091411    }
    14101412
     1413    if (host && strlen(host) < flat.Length())
     1414        return NS_ERROR_MALFORMED_URI; // found embedded null
     1415
    14111416    InvalidateCache();
    14121417    mHostEncoding = eEncoding_ASCII;
    14131418
  • TabularUnified netwerk/base/src/nsURLHelper.cpp

    diff -Naur mozilla.orig/netwerk/base/src/nsURLHelper.cpp mozilla/netwerk/base/src/nsURLHelper.cpp
    old new  
    507507PRBool
    508508net_IsValidScheme(const char *scheme, PRUint32 schemeLen)
    509509{
    510     // first char much be alpha
     510    // first char must be alpha
    511511    if (!nsCRT::IsAsciiAlpha(*scheme))
    512512        return PR_FALSE;
    513    
    514     for (; schemeLen && *scheme; ++scheme, --schemeLen) {
     513
     514    // nsCStrings may have embedded nulls -- reject those too
     515    for (; schemeLen; ++scheme, --schemeLen) {
    515516        if (!(nsCRT::IsAsciiAlpha(*scheme) ||
    516517              nsCRT::IsAsciiDigit(*scheme) ||
    517518              *scheme == '+' ||