Coverage Report

Created: 2026-02-26 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssh/ssherr-libcrypto.c
Line
Count
Source
1
/* $OpenBSD: ssherr-libcrypto.c,v 1.1 2026/02/06 23:31:29 dtucker Exp $ */
2
/*
3
 * Copyright (c) 2026 Darren Tucker
4
 *
5
 * Permission to use, copy, modify, and distribute this software for any
6
 * purpose with or without fee is hereby granted, provided that the above
7
 * copyright notice and this permission notice appear in all copies.
8
 *
9
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
 */
17
18
#include "includes.h"
19
20
#include <sys/types.h>
21
22
#include <errno.h>
23
#include <string.h>
24
25
#include "log.h"
26
27
#ifdef WITH_OPENSSL
28
#include <openssl/err.h>
29
30
const char *
31
ssherr_libcrypto(void)
32
0
{
33
0
  unsigned long e;
34
0
  static char buf[512];
35
0
  char msg[4096];
36
0
  const char *reason = NULL, *file, *data;
37
0
  int ln, fl;
38
39
0
  ERR_load_crypto_strings();
40
0
  while ((e = ERR_get_error_line_data(&file, &ln, &data, &fl)) != 0) {
41
0
    ERR_error_string_n(e, buf, sizeof(buf));
42
0
    snprintf(msg, sizeof(msg), "%s:%s:%d:%s", buf, file, ln,
43
0
        (fl & ERR_TXT_STRING) ? data : "");
44
0
    debug("libcrypto: '%s'", msg);
45
0
    if ((reason = ERR_reason_error_string(e)) != NULL)
46
0
      snprintf(buf, sizeof(buf), "error in libcrypto: %s",
47
0
          reason);
48
0
  }
49
0
  if (reason == NULL)
50
0
    return NULL;
51
0
  return buf;
52
0
}
53
#else
54
const char *
55
ssherr_libcrypto(void)
56
{
57
  return NULL;
58
}
59
#endif