diff options
Diffstat (limited to 'src/lib/libcrypto/buffer')
-rw-r--r-- | src/lib/libcrypto/buffer/Makefile | 90 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/Makefile.ssl | 94 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buf_err.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buffer.c | 31 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buffer.h | 17 |
5 files changed, 198 insertions, 46 deletions
diff --git a/src/lib/libcrypto/buffer/Makefile b/src/lib/libcrypto/buffer/Makefile new file mode 100644 index 0000000000..9f3a88d2d6 --- /dev/null +++ b/src/lib/libcrypto/buffer/Makefile | |||
@@ -0,0 +1,90 @@ | |||
1 | # | ||
2 | # OpenSSL/crypto/buffer/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= buffer | ||
6 | TOP= ../.. | ||
7 | CC= cc | ||
8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
9 | CFLAG=-g | ||
10 | MAKEFILE= Makefile | ||
11 | AR= ar r | ||
12 | |||
13 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
14 | |||
15 | GENERAL=Makefile | ||
16 | TEST= | ||
17 | APPS= | ||
18 | |||
19 | LIB=$(TOP)/libcrypto.a | ||
20 | LIBSRC= buffer.c buf_err.c | ||
21 | LIBOBJ= buffer.o buf_err.o | ||
22 | |||
23 | SRC= $(LIBSRC) | ||
24 | |||
25 | EXHEADER= buffer.h | ||
26 | HEADER= $(EXHEADER) | ||
27 | |||
28 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
29 | |||
30 | top: | ||
31 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
32 | |||
33 | all: lib | ||
34 | |||
35 | lib: $(LIBOBJ) | ||
36 | $(AR) $(LIB) $(LIBOBJ) | ||
37 | $(RANLIB) $(LIB) || echo Never mind. | ||
38 | @touch lib | ||
39 | |||
40 | files: | ||
41 | $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO | ||
42 | |||
43 | links: | ||
44 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
45 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
46 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
47 | |||
48 | install: | ||
49 | @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile... | ||
50 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | ||
51 | do \ | ||
52 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
53 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
54 | done; | ||
55 | |||
56 | tags: | ||
57 | ctags $(SRC) | ||
58 | |||
59 | tests: | ||
60 | |||
61 | lint: | ||
62 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
63 | |||
64 | depend: | ||
65 | @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... | ||
66 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
67 | |||
68 | dclean: | ||
69 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
70 | mv -f Makefile.new $(MAKEFILE) | ||
71 | |||
72 | clean: | ||
73 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
74 | |||
75 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
76 | |||
77 | buf_err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
78 | buf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
79 | buf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
80 | buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
81 | buf_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
82 | buf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
83 | buf_err.o: buf_err.c | ||
84 | buffer.o: ../../e_os.h ../../include/openssl/bio.h | ||
85 | buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
86 | buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
87 | buffer.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
88 | buffer.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
89 | buffer.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
90 | buffer.o: ../../include/openssl/symhacks.h ../cryptlib.h buffer.c | ||
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl new file mode 100644 index 0000000000..b131ca3078 --- /dev/null +++ b/src/lib/libcrypto/buffer/Makefile.ssl | |||
@@ -0,0 +1,94 @@ | |||
1 | # | ||
2 | # SSLeay/crypto/buffer/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= buffer | ||
6 | TOP= ../.. | ||
7 | CC= cc | ||
8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
9 | CFLAG=-g | ||
10 | INSTALL_PREFIX= | ||
11 | OPENSSLDIR= /usr/local/ssl | ||
12 | INSTALLTOP=/usr/local/ssl | ||
13 | MAKE= make -f Makefile.ssl | ||
14 | MAKEDEPPROG= makedepend | ||
15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
16 | MAKEFILE= Makefile.ssl | ||
17 | AR= ar r | ||
18 | |||
19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
20 | |||
21 | GENERAL=Makefile | ||
22 | TEST= | ||
23 | APPS= | ||
24 | |||
25 | LIB=$(TOP)/libcrypto.a | ||
26 | LIBSRC= buffer.c buf_err.c | ||
27 | LIBOBJ= buffer.o buf_err.o | ||
28 | |||
29 | SRC= $(LIBSRC) | ||
30 | |||
31 | EXHEADER= buffer.h | ||
32 | HEADER= $(EXHEADER) | ||
33 | |||
34 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
35 | |||
36 | top: | ||
37 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
38 | |||
39 | all: lib | ||
40 | |||
41 | lib: $(LIBOBJ) | ||
42 | $(AR) $(LIB) $(LIBOBJ) | ||
43 | $(RANLIB) $(LIB) || echo Never mind. | ||
44 | @touch lib | ||
45 | |||
46 | files: | ||
47 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
48 | |||
49 | links: | ||
50 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
51 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
52 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
53 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
54 | |||
55 | install: | ||
56 | @for i in $(EXHEADER) ; \ | ||
57 | do \ | ||
58 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
59 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
60 | done; | ||
61 | |||
62 | tags: | ||
63 | ctags $(SRC) | ||
64 | |||
65 | tests: | ||
66 | |||
67 | lint: | ||
68 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
69 | |||
70 | depend: | ||
71 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
72 | |||
73 | dclean: | ||
74 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
75 | mv -f Makefile.new $(MAKEFILE) | ||
76 | |||
77 | clean: | ||
78 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
79 | |||
80 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
81 | |||
82 | buf_err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
83 | buf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
84 | buf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
85 | buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
86 | buf_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
87 | buf_err.o: ../../include/openssl/symhacks.h buf_err.c | ||
88 | buffer.o: ../../e_os.h ../../include/openssl/bio.h | ||
89 | buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
90 | buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
91 | buffer.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
92 | buffer.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
93 | buffer.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
94 | buffer.o: ../cryptlib.h buffer.c | ||
diff --git a/src/lib/libcrypto/buffer/buf_err.c b/src/lib/libcrypto/buffer/buf_err.c index 3e25bbe879..1fc32a6861 100644 --- a/src/lib/libcrypto/buffer/buf_err.c +++ b/src/lib/libcrypto/buffer/buf_err.c | |||
@@ -70,12 +70,9 @@ | |||
70 | 70 | ||
71 | static ERR_STRING_DATA BUF_str_functs[]= | 71 | static ERR_STRING_DATA BUF_str_functs[]= |
72 | { | 72 | { |
73 | {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, | ||
74 | {ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, | 73 | {ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, |
75 | {ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, | ||
76 | {ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, | 74 | {ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, |
77 | {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, | 75 | {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, |
78 | {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, | ||
79 | {0,NULL} | 76 | {0,NULL} |
80 | }; | 77 | }; |
81 | 78 | ||
@@ -88,12 +85,15 @@ static ERR_STRING_DATA BUF_str_reasons[]= | |||
88 | 85 | ||
89 | void ERR_load_BUF_strings(void) | 86 | void ERR_load_BUF_strings(void) |
90 | { | 87 | { |
91 | #ifndef OPENSSL_NO_ERR | 88 | static int init=1; |
92 | 89 | ||
93 | if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) | 90 | if (init) |
94 | { | 91 | { |
92 | init=0; | ||
93 | #ifndef OPENSSL_NO_ERR | ||
95 | ERR_load_strings(0,BUF_str_functs); | 94 | ERR_load_strings(0,BUF_str_functs); |
96 | ERR_load_strings(0,BUF_str_reasons); | 95 | ERR_load_strings(0,BUF_str_reasons); |
97 | } | ||
98 | #endif | 96 | #endif |
97 | |||
98 | } | ||
99 | } | 99 | } |
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c index 3bf03c7eff..d96487e7db 100644 --- a/src/lib/libcrypto/buffer/buffer.c +++ b/src/lib/libcrypto/buffer/buffer.c | |||
@@ -149,7 +149,7 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len) | |||
149 | ret=OPENSSL_realloc_clean(str->data,str->max,n); | 149 | ret=OPENSSL_realloc_clean(str->data,str->max,n); |
150 | if (ret == NULL) | 150 | if (ret == NULL) |
151 | { | 151 | { |
152 | BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); | 152 | BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); |
153 | len=0; | 153 | len=0; |
154 | } | 154 | } |
155 | else | 155 | else |
@@ -164,41 +164,22 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len) | |||
164 | 164 | ||
165 | char *BUF_strdup(const char *str) | 165 | char *BUF_strdup(const char *str) |
166 | { | 166 | { |
167 | if (str == NULL) return(NULL); | ||
168 | return BUF_strndup(str, strlen(str)); | ||
169 | } | ||
170 | |||
171 | char *BUF_strndup(const char *str, size_t siz) | ||
172 | { | ||
173 | char *ret; | 167 | char *ret; |
168 | int n; | ||
174 | 169 | ||
175 | if (str == NULL) return(NULL); | 170 | if (str == NULL) return(NULL); |
176 | 171 | ||
177 | ret=OPENSSL_malloc(siz+1); | 172 | n=strlen(str); |
173 | ret=OPENSSL_malloc(n+1); | ||
178 | if (ret == NULL) | 174 | if (ret == NULL) |
179 | { | 175 | { |
180 | BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE); | 176 | BUFerr(BUF_F_BUF_STRDUP,ERR_R_MALLOC_FAILURE); |
181 | return(NULL); | 177 | return(NULL); |
182 | } | 178 | } |
183 | BUF_strlcpy(ret,str,siz+1); | 179 | memcpy(ret,str,n+1); |
184 | return(ret); | 180 | return(ret); |
185 | } | 181 | } |
186 | 182 | ||
187 | void *BUF_memdup(const void *data, size_t siz) | ||
188 | { | ||
189 | void *ret; | ||
190 | |||
191 | if (data == NULL) return(NULL); | ||
192 | |||
193 | ret=OPENSSL_malloc(siz); | ||
194 | if (ret == NULL) | ||
195 | { | ||
196 | BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE); | ||
197 | return(NULL); | ||
198 | } | ||
199 | return memcpy(ret, data, siz); | ||
200 | } | ||
201 | |||
202 | size_t BUF_strlcpy(char *dst, const char *src, size_t size) | 183 | size_t BUF_strlcpy(char *dst, const char *src, size_t size) |
203 | { | 184 | { |
204 | size_t l = 0; | 185 | size_t l = 0; |
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h index 1db9607450..465dc34f3f 100644 --- a/src/lib/libcrypto/buffer/buffer.h +++ b/src/lib/libcrypto/buffer/buffer.h | |||
@@ -59,35 +59,25 @@ | |||
59 | #ifndef HEADER_BUFFER_H | 59 | #ifndef HEADER_BUFFER_H |
60 | #define HEADER_BUFFER_H | 60 | #define HEADER_BUFFER_H |
61 | 61 | ||
62 | #include <openssl/ossl_typ.h> | ||
63 | |||
64 | #ifdef __cplusplus | 62 | #ifdef __cplusplus |
65 | extern "C" { | 63 | extern "C" { |
66 | #endif | 64 | #endif |
67 | 65 | ||
68 | #include <stddef.h> | 66 | #include <stddef.h> |
69 | |||
70 | #if !defined(NO_SYS_TYPES_H) | ||
71 | #include <sys/types.h> | 67 | #include <sys/types.h> |
72 | #endif | ||
73 | |||
74 | /* Already declared in ossl_typ.h */ | ||
75 | /* typedef struct buf_mem_st BUF_MEM; */ | ||
76 | 68 | ||
77 | struct buf_mem_st | 69 | typedef struct buf_mem_st |
78 | { | 70 | { |
79 | int length; /* current number of bytes */ | 71 | int length; /* current number of bytes */ |
80 | char *data; | 72 | char *data; |
81 | int max; /* size of buffer */ | 73 | int max; /* size of buffer */ |
82 | }; | 74 | } BUF_MEM; |
83 | 75 | ||
84 | BUF_MEM *BUF_MEM_new(void); | 76 | BUF_MEM *BUF_MEM_new(void); |
85 | void BUF_MEM_free(BUF_MEM *a); | 77 | void BUF_MEM_free(BUF_MEM *a); |
86 | int BUF_MEM_grow(BUF_MEM *str, int len); | 78 | int BUF_MEM_grow(BUF_MEM *str, int len); |
87 | int BUF_MEM_grow_clean(BUF_MEM *str, int len); | 79 | int BUF_MEM_grow_clean(BUF_MEM *str, int len); |
88 | char * BUF_strdup(const char *str); | 80 | char * BUF_strdup(const char *str); |
89 | char * BUF_strndup(const char *str, size_t siz); | ||
90 | void * BUF_memdup(const void *data, size_t siz); | ||
91 | 81 | ||
92 | /* safe string functions */ | 82 | /* safe string functions */ |
93 | size_t BUF_strlcpy(char *dst,const char *src,size_t siz); | 83 | size_t BUF_strlcpy(char *dst,const char *src,size_t siz); |
@@ -103,12 +93,9 @@ void ERR_load_BUF_strings(void); | |||
103 | /* Error codes for the BUF functions. */ | 93 | /* Error codes for the BUF functions. */ |
104 | 94 | ||
105 | /* Function codes. */ | 95 | /* Function codes. */ |
106 | #define BUF_F_BUF_MEMDUP 103 | ||
107 | #define BUF_F_BUF_MEM_GROW 100 | 96 | #define BUF_F_BUF_MEM_GROW 100 |
108 | #define BUF_F_BUF_MEM_GROW_CLEAN 105 | ||
109 | #define BUF_F_BUF_MEM_NEW 101 | 97 | #define BUF_F_BUF_MEM_NEW 101 |
110 | #define BUF_F_BUF_STRDUP 102 | 98 | #define BUF_F_BUF_STRDUP 102 |
111 | #define BUF_F_BUF_STRNDUP 104 | ||
112 | 99 | ||
113 | /* Reason codes. */ | 100 | /* Reason codes. */ |
114 | 101 | ||