Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 661f884ed921ce7afb60834b7f58a3bc5b9ad777 authored by Tomas Mraz on 11 September 2024, 15:41:30 UTC, committed by Tomas Mraz on 11 September 2024, 15:41:30 UTC
Fixup conflicting SSL_R_ECH_REQUIRED
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25435)
1 parent f303c9a
  • Files
  • Changes
  • c2cf0b7
  • /
  • test
  • /
  • strtoultest.c
Raw File
Cook and download a directory from the Software Heritage Vault

You have requested the cooking of the directory with identifier None into a standard tar.gz archive.

Are you sure you want to continue ?

Download a directory from the Software Heritage Vault

You have requested the download of the directory with identifier None as a standard tar.gz archive.

Are you sure you want to continue ?

Cook and download a revision from the Software Heritage Vault

You have requested the cooking of the history heading to revision with identifier swh:1:rev:661f884ed921ce7afb60834b7f58a3bc5b9ad777 into a bare git archive.

Are you sure you want to continue ?

Download a revision from the Software Heritage Vault

You have requested the download of the history heading to revision with identifier swh:1:rev:661f884ed921ce7afb60834b7f58a3bc5b9ad777 as a bare git archive.

Are you sure you want to continue ?

Invalid Email !

The provided email is not well-formed.

Download link has expired

The requested archive is no longer available for download from the Software Heritage Vault.

Do you want to cook it again ?

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • content
revision badge
swh:1:rev:661f884ed921ce7afb60834b7f58a3bc5b9ad777
content badge Iframe embedding
swh:1:cnt:90ec2b9a3dcda6c6a2d222373c75582ec5018a21
strtoultest.c
/*
 * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <openssl/crypto.h>
#include <internal/nelem.h>
#include "testutil.h"

struct strtoul_test_entry {
    char *input; /* the input string */
    int base; /* the base we are converting in */
    unsigned long expect_val; /* the expected value we should get */
    int expect_err;  /* the expected error we expect to receive */
    size_t expect_endptr_offset; /* the expected endptr offset, +1 for NULL */
};

static struct strtoul_test_entry strtoul_tests[] = {
    /* pass on conv "0" to 0 */
    {
        "0", 0, 0, 1, 1
    },
    /* pass on conv "12345" to 12345 */
    {
        "12345", 0, 12345, 1, 5
    },
    /* pass on conv "0x12345" to 0x12345, base 16 */
    {
        "0x12345", 0, 0x12345, 1, 7
    },
    /* pass on base 10 translation, endptr points to 'x' */
    {
        "0x12345", 10, 0, 1, 1
    },
#if ULONG_MAX == 4294967295
    /* pass on ULONG_MAX translation */
    {
        "4294967295", 0, ULONG_MAX, 1, 10
    },
#else
    {
        "18446744073709551615", 0, ULONG_MAX, 1, 20
    },
#endif

    /* fail on negative input */
    {
        "-1", 0, 0, 0, 0
    },
    /* fail on non-numerical input */
    {
        "abcd", 0, 0, 0, 0
    },
    /* pass on decimal input */
    {
        "1.0", 0, 1, 1, 1
    },
    /* Fail on decimal input without leading number */
    {
        ".1", 0, 0, 0, 0
    }
};

static int test_strtoul(int idx)
{
    unsigned long val;
    char *endptr = NULL;
    int err;
    struct strtoul_test_entry *test = &strtoul_tests[idx];

    /*
     * For each test, convert the string to an unsigned long
     */
    err = OPENSSL_strtoul(test->input, &endptr, test->base, &val);

    /*
     * Check to ensure the error returned is expected
     */
    if (!TEST_int_eq(err, test->expect_err))
        return 0;
    /*
     * Confirm that the endptr points to where we expect
     */
    if (!TEST_ptr_eq(endptr, &test->input[test->expect_endptr_offset]))
        return 0;
    /*
     * And check that we received the proper translated value
     * Note, we only check the value if the conversion passed
     */
    if (test->expect_err == 1) {
        if (!TEST_ulong_eq(val, test->expect_val))
            return 0;
    }
    return 1;

}

int setup_tests(void)
{
    ADD_ALL_TESTS(test_strtoul, OSSL_NELEM(strtoul_tests));
    return 1;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top