diff options
| author | miod <> | 2014-04-23 20:59:36 +0000 |
|---|---|---|
| committer | miod <> | 2014-04-23 20:59:36 +0000 |
| commit | dcce575a546a9cdbd9a85c026bcc519e98d71f02 (patch) | |
| tree | 1096190589e0961bf69454ee8670bf22d4a20a41 /src/lib/libcrypto/bio/bss_dgram.c | |
| parent | f6e0ba05471bd4260c450caf587f69f7004b8fb7 (diff) | |
| download | openbsd-dcce575a546a9cdbd9a85c026bcc519e98d71f02.tar.gz openbsd-dcce575a546a9cdbd9a85c026bcc519e98d71f02.tar.bz2 openbsd-dcce575a546a9cdbd9a85c026bcc519e98d71f02.zip | |
The usual idiom to cope with systems not defining socklen_t is to add a
#define socklen_t int
somewhere (or a typedef, whatever gives you an integer type of the size
your system expects as the 3rd argument of accept(2), really).
OpenSSL here is a bit more creative by using an union of an int and a size_t,
and extra code if sizeof(int) != sizeof(size_t) in order to recover the
proper size. With a comment mentioning that this has no chance to work on
a platform with a stack growing up and accept() returning an int, fortunately
this seems to work on HP-UX.
Switch to the light side of the force and declare and use socklen_t variables,
period. If your system does not define socklen_t, consider bringing it back
to your vendor for a refund.
ok matthew@ tedu@
Diffstat (limited to 'src/lib/libcrypto/bio/bss_dgram.c')
| -rw-r--r-- | src/lib/libcrypto/bio/bss_dgram.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index a3b5bb6574..ab269aeba3 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c | |||
| @@ -331,13 +331,7 @@ dgram_read(BIO *b, char *out, int outl) | |||
| 331 | bio_dgram_data *data = (bio_dgram_data *)b->ptr; | 331 | bio_dgram_data *data = (bio_dgram_data *)b->ptr; |
| 332 | 332 | ||
| 333 | struct { | 333 | struct { |
| 334 | /* | 334 | socklen_t len; |
| 335 | * See commentary in b_sock.c. <appro> | ||
| 336 | */ | ||
| 337 | union { | ||
| 338 | size_t s; | ||
| 339 | int i; | ||
| 340 | } len; | ||
| 341 | union { | 335 | union { |
| 342 | struct sockaddr sa; | 336 | struct sockaddr sa; |
| 343 | struct sockaddr_in sa_in; | 337 | struct sockaddr_in sa_in; |
| @@ -345,18 +339,13 @@ dgram_read(BIO *b, char *out, int outl) | |||
| 345 | } peer; | 339 | } peer; |
| 346 | } sa; | 340 | } sa; |
| 347 | 341 | ||
| 348 | sa.len.s = 0; | 342 | sa.len = sizeof(sa.peer); |
| 349 | sa.len.i = sizeof(sa.peer); | ||
| 350 | 343 | ||
| 351 | if (out != NULL) { | 344 | if (out != NULL) { |
| 352 | errno = 0; | 345 | errno = 0; |
| 353 | memset(&sa.peer, 0x00, sizeof(sa.peer)); | 346 | memset(&sa.peer, 0x00, sizeof(sa.peer)); |
| 354 | dgram_adjust_rcv_timeout(b); | 347 | dgram_adjust_rcv_timeout(b); |
| 355 | ret = recvfrom(b->num, out, outl, 0, &sa.peer.sa,(void *)&sa.len); | 348 | ret = recvfrom(b->num, out, outl, 0, &sa.peer.sa, &sa.len); |
| 356 | if (sizeof(sa.len.i) != sizeof(sa.len.s) && sa.len.i == 0) { | ||
| 357 | OPENSSL_assert(sa.len.s <= sizeof(sa.peer)); | ||
| 358 | sa.len.i = (int)sa.len.s; | ||
| 359 | } | ||
| 360 | 349 | ||
| 361 | if (! data->connected && ret >= 0) | 350 | if (! data->connected && ret >= 0) |
| 362 | BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); | 351 | BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); |
