Blame crypto/getenv.c

Packit c4476c
/*
Packit c4476c
 * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#ifndef _GNU_SOURCE
Packit c4476c
# define _GNU_SOURCE
Packit c4476c
#endif
Packit c4476c
Packit c4476c
#include <stdlib.h>
Packit c4476c
#include "internal/cryptlib.h"
Packit c4476c
Packit c4476c
char *ossl_safe_getenv(const char *name)
Packit c4476c
{
Packit c4476c
#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
Packit c4476c
# if __GLIBC_PREREQ(2, 17)
Packit c4476c
#  define SECURE_GETENV
Packit c4476c
    return secure_getenv(name);
Packit c4476c
# endif
Packit c4476c
#endif
Packit c4476c
Packit c4476c
#ifndef SECURE_GETENV
Packit c4476c
    if (OPENSSL_issetugid())
Packit c4476c
        return NULL;
Packit c4476c
    return getenv(name);
Packit c4476c
#endif
Packit c4476c
}