security/nss/lib/ssl/sslerr.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/ssl/sslerr.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/*
     1.5 + * Function to set error code only when meaningful error has not already 
     1.6 + * been set.
     1.7 + *
     1.8 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.9 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    1.10 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.11 +
    1.12 +#include "prerror.h"
    1.13 +#include "secerr.h"
    1.14 +#include "sslerr.h"
    1.15 +#include "seccomon.h"
    1.16 +
    1.17 +/* look at the current value of PR_GetError, and evaluate it to see
    1.18 + * if it is meaningful or meaningless (out of context). 
    1.19 + * If it is meaningless, replace it with the hiLevelError.
    1.20 + * Returns the chosen error value.
    1.21 + */
    1.22 +int
    1.23 +ssl_MapLowLevelError(int hiLevelError)
    1.24 +{
    1.25 +    int oldErr	= PORT_GetError();
    1.26 +
    1.27 +    switch (oldErr) {
    1.28 +
    1.29 +    case 0:
    1.30 +    case PR_IO_ERROR:
    1.31 +    case SEC_ERROR_IO:
    1.32 +    case SEC_ERROR_BAD_DATA:
    1.33 +    case SEC_ERROR_LIBRARY_FAILURE:
    1.34 +    case SEC_ERROR_EXTENSION_NOT_FOUND:
    1.35 +    case SSL_ERROR_BAD_CLIENT:
    1.36 +    case SSL_ERROR_BAD_SERVER:
    1.37 +    case SSL_ERROR_SESSION_NOT_FOUND:
    1.38 +    	PORT_SetError(hiLevelError);
    1.39 +	return hiLevelError;
    1.40 +
    1.41 +    default:	/* leave the majority of error codes alone. */
    1.42 +	return oldErr;
    1.43 +    }
    1.44 +}

mercurial