diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libssl/bs_cbs.c | 16 | ||||
-rw-r--r-- | src/lib/libssl/bytestring.h | 10 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bs_cbs.c | 16 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bytestring.h | 10 |
4 files changed, 48 insertions, 4 deletions
diff --git a/src/lib/libssl/bs_cbs.c b/src/lib/libssl/bs_cbs.c index 1368fe0fd7..b36ba489f3 100644 --- a/src/lib/libssl/bs_cbs.c +++ b/src/lib/libssl/bs_cbs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbs.c,v 1.11 2015/06/17 07:00:22 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbs.c,v 1.12 2015/06/17 07:06:22 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -96,6 +96,20 @@ CBS_strdup(const CBS *cbs, char **out_ptr) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | int | 98 | int |
99 | CBS_write_bytes(const CBS *cbs, uint8_t *dst, size_t dst_len, size_t *copied) | ||
100 | { | ||
101 | if (dst_len < cbs->len) | ||
102 | return 0; | ||
103 | |||
104 | memmove(dst, cbs->data, cbs->len); | ||
105 | |||
106 | if (copied != NULL) | ||
107 | *copied = cbs->len; | ||
108 | |||
109 | return 1; | ||
110 | } | ||
111 | |||
112 | int | ||
99 | CBS_contains_zero_byte(const CBS *cbs) | 113 | CBS_contains_zero_byte(const CBS *cbs) |
100 | { | 114 | { |
101 | return memchr(cbs->data, 0, cbs->len) != NULL; | 115 | return memchr(cbs->data, 0, cbs->len) != NULL; |
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index 80ca00d77a..2eb18e207d 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.10 2015/06/17 07:00:22 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.11 2015/06/17 07:06:22 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -92,6 +92,14 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len); | |||
92 | int CBS_strdup(const CBS *cbs, char **out_ptr); | 92 | int CBS_strdup(const CBS *cbs, char **out_ptr); |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * CBS_write_bytes writes all of the remaining data from |cbs| into |dst| | ||
96 | * if it is at most |dst_len| bytes. If |copied| is not NULL, it will be set | ||
97 | * to the amount copied. It returns one on success and zero otherwise. | ||
98 | */ | ||
99 | int CBS_write_bytes(const CBS *cbs, uint8_t *dst, size_t dst_len, | ||
100 | size_t *copied); | ||
101 | |||
102 | /* | ||
95 | * CBS_contains_zero_byte returns one if the current contents of |cbs| contains | 103 | * CBS_contains_zero_byte returns one if the current contents of |cbs| contains |
96 | * a NUL byte and zero otherwise. | 104 | * a NUL byte and zero otherwise. |
97 | */ | 105 | */ |
diff --git a/src/lib/libssl/src/ssl/bs_cbs.c b/src/lib/libssl/src/ssl/bs_cbs.c index 1368fe0fd7..b36ba489f3 100644 --- a/src/lib/libssl/src/ssl/bs_cbs.c +++ b/src/lib/libssl/src/ssl/bs_cbs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbs.c,v 1.11 2015/06/17 07:00:22 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbs.c,v 1.12 2015/06/17 07:06:22 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -96,6 +96,20 @@ CBS_strdup(const CBS *cbs, char **out_ptr) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | int | 98 | int |
99 | CBS_write_bytes(const CBS *cbs, uint8_t *dst, size_t dst_len, size_t *copied) | ||
100 | { | ||
101 | if (dst_len < cbs->len) | ||
102 | return 0; | ||
103 | |||
104 | memmove(dst, cbs->data, cbs->len); | ||
105 | |||
106 | if (copied != NULL) | ||
107 | *copied = cbs->len; | ||
108 | |||
109 | return 1; | ||
110 | } | ||
111 | |||
112 | int | ||
99 | CBS_contains_zero_byte(const CBS *cbs) | 113 | CBS_contains_zero_byte(const CBS *cbs) |
100 | { | 114 | { |
101 | return memchr(cbs->data, 0, cbs->len) != NULL; | 115 | return memchr(cbs->data, 0, cbs->len) != NULL; |
diff --git a/src/lib/libssl/src/ssl/bytestring.h b/src/lib/libssl/src/ssl/bytestring.h index 80ca00d77a..2eb18e207d 100644 --- a/src/lib/libssl/src/ssl/bytestring.h +++ b/src/lib/libssl/src/ssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.10 2015/06/17 07:00:22 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.11 2015/06/17 07:06:22 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -92,6 +92,14 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len); | |||
92 | int CBS_strdup(const CBS *cbs, char **out_ptr); | 92 | int CBS_strdup(const CBS *cbs, char **out_ptr); |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * CBS_write_bytes writes all of the remaining data from |cbs| into |dst| | ||
96 | * if it is at most |dst_len| bytes. If |copied| is not NULL, it will be set | ||
97 | * to the amount copied. It returns one on success and zero otherwise. | ||
98 | */ | ||
99 | int CBS_write_bytes(const CBS *cbs, uint8_t *dst, size_t dst_len, | ||
100 | size_t *copied); | ||
101 | |||
102 | /* | ||
95 | * CBS_contains_zero_byte returns one if the current contents of |cbs| contains | 103 | * CBS_contains_zero_byte returns one if the current contents of |cbs| contains |
96 | * a NUL byte and zero otherwise. | 104 | * a NUL byte and zero otherwise. |
97 | */ | 105 | */ |