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 48e7b18efcd77890f36272b46a4603d15a1ac221 authored by Neil Horman on 26 July 2024, 15:01:05 UTC, committed by Neil Horman on 09 August 2024, 12:28:38 UTC
limit bignums to 128 bytes
Keep us from spinning forever doing huge amounts of math in the fuzzer

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25013)

(cherry picked from commit f0768376e1639d12a328745ef69c90d584138074)
1 parent 67c6330
  • Files
  • Changes
  • 6cdbfeb
  • /
  • include
  • /
  • internal
  • /
  • list.h
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:48e7b18efcd77890f36272b46a4603d15a1ac221 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:48e7b18efcd77890f36272b46a4603d15a1ac221 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:48e7b18efcd77890f36272b46a4603d15a1ac221
content badge Iframe embedding
swh:1:cnt:fdd356c407d1c5966002767aac69d5a58d83fd72
list.h
/*
 * Copyright 2022 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
 */

#ifndef OSSL_INTERNAL_LIST_H
# define OSSL_INTERNAL_LIST_H
# pragma once

# include <string.h>
# include <assert.h>

# ifdef NDEBUG
#  define OSSL_LIST_DBG(x)
# else
#  define OSSL_LIST_DBG(x) x;
# endif

/* Define a list structure */
# define OSSL_LIST(name) OSSL_LIST_ ## name

/* Define fields to include an element of a list */
# define OSSL_LIST_MEMBER(name, type)                                       \
    struct {                                                                \
        type *next, *prev;                                                  \
        OSSL_LIST_DBG(struct ossl_list_st_ ## name *list)                   \
    } ossl_list_ ## name

# define DEFINE_LIST_OF(name, type)                                         \
    typedef struct ossl_list_st_ ## name OSSL_LIST(name);                   \
    struct ossl_list_st_ ## name {                                          \
        type *alpha, *omega;                                                \
        size_t num_elems;                                                   \
    };                                                                      \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_init(OSSL_LIST(name) *list)                          \
    {                                                                       \
        memset(list, 0, sizeof(*list));                                     \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_init_elem(type *elem)                                \
    {                                                                       \
        memset(&elem->ossl_list_ ## name, 0,                                \
               sizeof(elem->ossl_list_ ## name));                           \
    }                                                                       \
    static ossl_unused ossl_inline int                                      \
    ossl_list_##name##_is_empty(const OSSL_LIST(name) *list)                \
    {                                                                       \
        return list->num_elems == 0;                                        \
    }                                                                       \
    static ossl_unused ossl_inline size_t                                   \
    ossl_list_##name##_num(const OSSL_LIST(name) *list)                     \
    {                                                                       \
        return list->num_elems;                                             \
    }                                                                       \
    static ossl_unused ossl_inline type *                                   \
    ossl_list_##name##_head(const OSSL_LIST(name) *list)                    \
    {                                                                       \
        assert(list->alpha == NULL                                          \
               || list->alpha->ossl_list_ ## name.list == list);            \
        return list->alpha;                                                 \
    }                                                                       \
    static ossl_unused ossl_inline type *                                   \
    ossl_list_##name##_tail(const OSSL_LIST(name) *list)                    \
    {                                                                       \
        assert(list->omega == NULL                                          \
               || list->omega->ossl_list_ ## name.list == list);            \
        return list->omega;                                                 \
    }                                                                       \
    static ossl_unused ossl_inline type *                                   \
    ossl_list_##name##_next(const type *elem)                               \
    {                                                                       \
        assert(elem->ossl_list_ ## name.next == NULL                        \
               || elem->ossl_list_ ## name.next                             \
                      ->ossl_list_ ## name.prev == elem);                   \
        return elem->ossl_list_ ## name.next;                               \
    }                                                                       \
    static ossl_unused ossl_inline type *                                   \
    ossl_list_##name##_prev(const type *elem)                               \
    {                                                                       \
        assert(elem->ossl_list_ ## name.prev == NULL                        \
               || elem->ossl_list_ ## name.prev                             \
                      ->ossl_list_ ## name.next == elem);                   \
        return elem->ossl_list_ ## name.prev;                               \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_remove(OSSL_LIST(name) *list, type *elem)            \
    {                                                                       \
        assert(elem->ossl_list_ ## name.list == list);                      \
        OSSL_LIST_DBG(elem->ossl_list_ ## name.list = NULL)                 \
        if (list->alpha == elem)                                            \
            list->alpha = elem->ossl_list_ ## name.next;                    \
        if (list->omega == elem)                                            \
            list->omega = elem->ossl_list_ ## name.prev;                    \
        if (elem->ossl_list_ ## name.prev != NULL)                          \
            elem->ossl_list_ ## name.prev->ossl_list_ ## name.next =        \
                    elem->ossl_list_ ## name.next;                          \
        if (elem->ossl_list_ ## name.next != NULL)                          \
            elem->ossl_list_ ## name.next->ossl_list_ ## name.prev =        \
                    elem->ossl_list_ ## name.prev;                          \
        list->num_elems--;                                                  \
        memset(&elem->ossl_list_ ## name, 0,                                \
               sizeof(elem->ossl_list_ ## name));                           \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_insert_head(OSSL_LIST(name) *list, type *elem)       \
    {                                                                       \
        assert(elem->ossl_list_ ## name.list == NULL);                      \
        OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list)                 \
        if (list->alpha != NULL)                                            \
            list->alpha->ossl_list_ ## name.prev = elem;                    \
        elem->ossl_list_ ## name.next = list->alpha;                        \
        elem->ossl_list_ ## name.prev = NULL;                               \
        list->alpha = elem;                                                 \
        if (list->omega == NULL)                                            \
            list->omega = elem;                                             \
        list->num_elems++;                                                  \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_insert_tail(OSSL_LIST(name) *list, type *elem)       \
    {                                                                       \
        assert(elem->ossl_list_ ## name.list == NULL);                      \
        OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list)                 \
        if (list->omega != NULL)                                            \
            list->omega->ossl_list_ ## name.next = elem;                    \
        elem->ossl_list_ ## name.prev = list->omega;                        \
        elem->ossl_list_ ## name.next = NULL;                               \
        list->omega = elem;                                                 \
        if (list->alpha == NULL)                                            \
            list->alpha = elem;                                             \
        list->num_elems++;                                                  \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_insert_before(OSSL_LIST(name) *list, type *e,        \
                                     type *elem)                            \
    {                                                                       \
        assert(elem->ossl_list_ ## name.list == NULL);                      \
        OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list)                 \
        elem->ossl_list_ ## name.next = e;                                  \
        elem->ossl_list_ ## name.prev = e->ossl_list_ ## name.prev;         \
        if (e->ossl_list_ ## name.prev != NULL)                             \
            e->ossl_list_ ## name.prev->ossl_list_ ## name.next = elem;     \
        e->ossl_list_ ## name.prev = elem;                                  \
        if (list->alpha == e)                                               \
            list->alpha = elem;                                             \
        list->num_elems++;                                                  \
    }                                                                       \
    static ossl_unused ossl_inline void                                     \
    ossl_list_##name##_insert_after(OSSL_LIST(name) *list, type *e,         \
                                    type *elem)                             \
    {                                                                       \
        assert(elem->ossl_list_ ## name.list == NULL);                      \
        OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list)                 \
        elem->ossl_list_ ## name.prev = e;                                  \
        elem->ossl_list_ ## name.next = e->ossl_list_ ## name.next;         \
        if (e->ossl_list_ ## name.next != NULL)                             \
            e->ossl_list_ ## name.next->ossl_list_ ## name.prev = elem;     \
        e->ossl_list_ ## name.next = elem;                                  \
        if (list->omega == e)                                               \
            list->omega = elem;                                             \
        list->num_elems++;                                                  \
    }                                                                       \
    struct ossl_list_st_ ## name

#endif
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