summaryrefslogtreecommitdiff
path: root/src/lib/libssl/bs_cbs.c
diff options
context:
space:
mode:
authordoug <>2015-06-17 07:06:22 +0000
committerdoug <>2015-06-17 07:06:22 +0000
commit1a6ec4dba6f1322011c578d9ef1a3d4898ddfacd (patch)
tree93fbc20cc8335f820378205df913c380ea091808 /src/lib/libssl/bs_cbs.c
parent7489a76f28fc9e40d91abd387e7e07cf8e913e7e (diff)
downloadopenbsd-1a6ec4dba6f1322011c578d9ef1a3d4898ddfacd.tar.gz
openbsd-1a6ec4dba6f1322011c578d9ef1a3d4898ddfacd.tar.bz2
openbsd-1a6ec4dba6f1322011c578d9ef1a3d4898ddfacd.zip
Add CBS_write_bytes() to copy the remaining CBS bytes to the caller.
This is a common operation when dealing with CBS. ok miod@ jsing@
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/bs_cbs.c16
1 files changed, 15 insertions, 1 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
98int 98int
99CBS_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
112int
99CBS_contains_zero_byte(const CBS *cbs) 113CBS_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;