diff options
author | tb <> | 2023-07-28 10:17:21 +0000 |
---|---|---|
committer | tb <> | 2023-07-28 10:17:21 +0000 |
commit | 39fd8a543e6f18ed3accea6db537f4a36fdb017d (patch) | |
tree | dc39f416023b0f99ec8cf84560368de1ed8d4d71 | |
parent | e56dd594e13ac1e9a8e37ebda000cf90e2a9ad20 (diff) | |
download | openbsd-39fd8a543e6f18ed3accea6db537f4a36fdb017d.tar.gz openbsd-39fd8a543e6f18ed3accea6db537f4a36fdb017d.tar.bz2 openbsd-39fd8a543e6f18ed3accea6db537f4a36fdb017d.zip |
Remove BUF_[a-z]* API
This are a bunch of strange string handlers with NULL checks that make
no real sense except to some devs who like to sprinkle them everywhere.
Fortunately, nothing uses these anymore, so they can go.
ok jsing
-rw-r--r-- | src/lib/libcrypto/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buf_str.c | 79 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buffer.h | 18 |
4 files changed, 2 insertions, 104 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index 6d9a6ca858..a174cc1b20 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.147 2023/07/28 10:02:11 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.148 2023/07/28 10:17:21 tb Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
@@ -201,7 +201,6 @@ SRCS+= bn_word.c | |||
201 | 201 | ||
202 | # buffer/ | 202 | # buffer/ |
203 | SRCS+= buf_err.c | 203 | SRCS+= buf_err.c |
204 | SRCS+= buf_str.c | ||
205 | SRCS+= buffer.c | 204 | SRCS+= buffer.c |
206 | 205 | ||
207 | # bytestring/ | 206 | # bytestring/ |
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 94a22938fc..2f081c1a4c 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -495,12 +495,6 @@ BUF_MEM_free | |||
495 | BUF_MEM_grow | 495 | BUF_MEM_grow |
496 | BUF_MEM_grow_clean | 496 | BUF_MEM_grow_clean |
497 | BUF_MEM_new | 497 | BUF_MEM_new |
498 | BUF_memdup | ||
499 | BUF_reverse | ||
500 | BUF_strdup | ||
501 | BUF_strlcat | ||
502 | BUF_strlcpy | ||
503 | BUF_strndup | ||
504 | CAST_cbc_encrypt | 498 | CAST_cbc_encrypt |
505 | CAST_cfb64_encrypt | 499 | CAST_cfb64_encrypt |
506 | CAST_decrypt | 500 | CAST_decrypt |
diff --git a/src/lib/libcrypto/buffer/buf_str.c b/src/lib/libcrypto/buffer/buf_str.c deleted file mode 100644 index 4ebc4717c8..0000000000 --- a/src/lib/libcrypto/buffer/buf_str.c +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /* $OpenBSD: buf_str.c,v 1.11 2017/04/09 14:33:21 jsing Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2014 Bob Beck | ||
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 <stdlib.h> | ||
19 | #include <stdio.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | #include <openssl/buffer.h> | ||
23 | #include <openssl/err.h> | ||
24 | |||
25 | /* | ||
26 | * XXX these functions accept a NULL arg and return NULL | ||
27 | * when the standard ones do not. we should at an appropriate | ||
28 | * time change these to find the bad callers | ||
29 | */ | ||
30 | |||
31 | char * | ||
32 | BUF_strdup(const char *str) | ||
33 | { | ||
34 | char *ret = NULL; | ||
35 | |||
36 | if (str != NULL) { | ||
37 | if ((ret = strdup(str)) == NULL) | ||
38 | BUFerror(ERR_R_MALLOC_FAILURE); | ||
39 | } | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | char * | ||
44 | BUF_strndup(const char *str, size_t siz) | ||
45 | { | ||
46 | char *ret = NULL; | ||
47 | |||
48 | if (str != NULL) { | ||
49 | if ((ret = strndup(str, siz)) == NULL) | ||
50 | BUFerror(ERR_R_MALLOC_FAILURE); | ||
51 | } | ||
52 | return ret; | ||
53 | } | ||
54 | |||
55 | void * | ||
56 | BUF_memdup(const void *data, size_t siz) | ||
57 | { | ||
58 | void *ret = NULL; | ||
59 | |||
60 | if (data != NULL) { | ||
61 | if ((ret = malloc(siz)) == NULL) | ||
62 | BUFerror(ERR_R_MALLOC_FAILURE); | ||
63 | else | ||
64 | (void) memcpy(ret, data, siz); | ||
65 | } | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | size_t | ||
70 | BUF_strlcpy(char *dst, const char *src, size_t size) | ||
71 | { | ||
72 | return strlcpy(dst, src, size); | ||
73 | } | ||
74 | |||
75 | size_t | ||
76 | BUF_strlcat(char *dst, const char *src, size_t size) | ||
77 | { | ||
78 | return strlcat(dst, src, size); | ||
79 | } | ||
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h index c210bfd1c5..d461d6493c 100644 --- a/src/lib/libcrypto/buffer/buffer.h +++ b/src/lib/libcrypto/buffer/buffer.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: buffer.h,v 1.16 2022/07/12 14:42:48 kn Exp $ */ | 1 | /* $OpenBSD: buffer.h,v 1.17 2023/07/28 10:17:21 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -58,9 +58,6 @@ | |||
58 | 58 | ||
59 | #ifndef HEADER_BUFFER_H | 59 | #ifndef HEADER_BUFFER_H |
60 | #define HEADER_BUFFER_H | 60 | #define HEADER_BUFFER_H |
61 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__) | ||
62 | #define __bounded__(x, y, z) | ||
63 | #endif | ||
64 | 61 | ||
65 | #include <openssl/ossl_typ.h> | 62 | #include <openssl/ossl_typ.h> |
66 | 63 | ||
@@ -85,19 +82,6 @@ void BUF_MEM_free(BUF_MEM *a); | |||
85 | int BUF_MEM_grow(BUF_MEM *str, size_t len); | 82 | int BUF_MEM_grow(BUF_MEM *str, size_t len); |
86 | int BUF_MEM_grow_clean(BUF_MEM *str, size_t len); | 83 | int BUF_MEM_grow_clean(BUF_MEM *str, size_t len); |
87 | 84 | ||
88 | #ifndef LIBRESSL_INTERNAL | ||
89 | char * BUF_strdup(const char *str); | ||
90 | char * BUF_strndup(const char *str, size_t siz); | ||
91 | void * BUF_memdup(const void *data, size_t siz); | ||
92 | void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); | ||
93 | |||
94 | /* safe string functions */ | ||
95 | size_t BUF_strlcpy(char *dst, const char *src, size_t siz) | ||
96 | __attribute__ ((__bounded__(__string__,1,3))); | ||
97 | size_t BUF_strlcat(char *dst, const char *src, size_t siz) | ||
98 | __attribute__ ((__bounded__(__string__,1,3))); | ||
99 | #endif | ||
100 | |||
101 | void ERR_load_BUF_strings(void); | 85 | void ERR_load_BUF_strings(void); |
102 | 86 | ||
103 | /* Error codes for the BUF functions. */ | 87 | /* Error codes for the BUF functions. */ |