diff options
Diffstat (limited to 'src/lib/libcrypto/buffer')
-rw-r--r-- | src/lib/libcrypto/buffer/Makefile.ssl | 94 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buffer.c | 57 | ||||
-rw-r--r-- | src/lib/libcrypto/buffer/buffer.h | 9 |
3 files changed, 94 insertions, 66 deletions
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl new file mode 100644 index 0000000000..240a6b9a89 --- /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/buffer.c b/src/lib/libcrypto/buffer/buffer.c index d96487e7db..9299baba9e 100644 --- a/src/lib/libcrypto/buffer/buffer.c +++ b/src/lib/libcrypto/buffer/buffer.c | |||
@@ -125,43 +125,6 @@ int BUF_MEM_grow(BUF_MEM *str, int len) | |||
125 | return(len); | 125 | return(len); |
126 | } | 126 | } |
127 | 127 | ||
128 | int BUF_MEM_grow_clean(BUF_MEM *str, int len) | ||
129 | { | ||
130 | char *ret; | ||
131 | unsigned int n; | ||
132 | |||
133 | if (str->length >= len) | ||
134 | { | ||
135 | memset(&str->data[len],0,str->length-len); | ||
136 | str->length=len; | ||
137 | return(len); | ||
138 | } | ||
139 | if (str->max >= len) | ||
140 | { | ||
141 | memset(&str->data[str->length],0,len-str->length); | ||
142 | str->length=len; | ||
143 | return(len); | ||
144 | } | ||
145 | n=(len+3)/3*4; | ||
146 | if (str->data == NULL) | ||
147 | ret=OPENSSL_malloc(n); | ||
148 | else | ||
149 | ret=OPENSSL_realloc_clean(str->data,str->max,n); | ||
150 | if (ret == NULL) | ||
151 | { | ||
152 | BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); | ||
153 | len=0; | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | str->data=ret; | ||
158 | str->max=n; | ||
159 | memset(&str->data[str->length],0,len-str->length); | ||
160 | str->length=len; | ||
161 | } | ||
162 | return(len); | ||
163 | } | ||
164 | |||
165 | char *BUF_strdup(const char *str) | 128 | char *BUF_strdup(const char *str) |
166 | { | 129 | { |
167 | char *ret; | 130 | char *ret; |
@@ -180,23 +143,3 @@ char *BUF_strdup(const char *str) | |||
180 | return(ret); | 143 | return(ret); |
181 | } | 144 | } |
182 | 145 | ||
183 | size_t BUF_strlcpy(char *dst, const char *src, size_t size) | ||
184 | { | ||
185 | size_t l = 0; | ||
186 | for(; size > 1 && *src; size--) | ||
187 | { | ||
188 | *dst++ = *src++; | ||
189 | l++; | ||
190 | } | ||
191 | if (size) | ||
192 | *dst = '\0'; | ||
193 | return l + strlen(src); | ||
194 | } | ||
195 | |||
196 | size_t BUF_strlcat(char *dst, const char *src, size_t size) | ||
197 | { | ||
198 | size_t l = 0; | ||
199 | for(; size > 0 && *dst; size--, dst++) | ||
200 | l++; | ||
201 | return l + BUF_strlcpy(dst, src, size); | ||
202 | } | ||
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h index 465dc34f3f..11e2d0359a 100644 --- a/src/lib/libcrypto/buffer/buffer.h +++ b/src/lib/libcrypto/buffer/buffer.h | |||
@@ -63,9 +63,6 @@ | |||
63 | extern "C" { | 63 | extern "C" { |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #include <stddef.h> | ||
67 | #include <sys/types.h> | ||
68 | |||
69 | typedef struct buf_mem_st | 66 | typedef struct buf_mem_st |
70 | { | 67 | { |
71 | int length; /* current number of bytes */ | 68 | int length; /* current number of bytes */ |
@@ -76,14 +73,8 @@ typedef struct buf_mem_st | |||
76 | BUF_MEM *BUF_MEM_new(void); | 73 | BUF_MEM *BUF_MEM_new(void); |
77 | void BUF_MEM_free(BUF_MEM *a); | 74 | void BUF_MEM_free(BUF_MEM *a); |
78 | int BUF_MEM_grow(BUF_MEM *str, int len); | 75 | int BUF_MEM_grow(BUF_MEM *str, int len); |
79 | int BUF_MEM_grow_clean(BUF_MEM *str, int len); | ||
80 | char * BUF_strdup(const char *str); | 76 | char * BUF_strdup(const char *str); |
81 | 77 | ||
82 | /* safe string functions */ | ||
83 | size_t BUF_strlcpy(char *dst,const char *src,size_t siz); | ||
84 | size_t BUF_strlcat(char *dst,const char *src,size_t siz); | ||
85 | |||
86 | |||
87 | /* BEGIN ERROR CODES */ | 78 | /* BEGIN ERROR CODES */ |
88 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 79 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
89 | * made after this point may be overwritten when the script is next run. | 80 | * made after this point may be overwritten when the script is next run. |