summaryrefslogtreecommitdiffstats
path: root/ssl/packet_locl.h
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2016-02-01 15:26:18 +0100
committerEmilia Kasper <emilia@openssl.org>2016-02-01 16:21:57 +0100
commitb69817449315f3818a8472468b3328ea755819db (patch)
treebb2abb48ce582d6d9b8fdc6e216ee0028deff817 /ssl/packet_locl.h
parent0c787647ded59a81311d905024bc93df5d3a061c (diff)
constify PACKET
PACKET contents should be read-only. To achieve this, also - constify two user callbacks - constify BUF_reverse. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r--ssl/packet_locl.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index b4337e4682..48767b6728 100644
--- a/ssl/packet_locl.h
+++ b/ssl/packet_locl.h
@@ -72,7 +72,7 @@ extern "C" {
typedef struct {
/* Pointer to where we are currently reading from */
- unsigned char *curr;
+ const unsigned char *curr;
/* Number of bytes remaining */
size_t remaining;
} PACKET;
@@ -95,10 +95,8 @@ static ossl_inline size_t PACKET_remaining(const PACKET *pkt)
/*
* Returns a pointer to the PACKET's current position.
* For use in non-PACKETized APIs.
- * TODO(openssl-team): this should return 'const unsigned char*' but can't
- * currently because legacy code passes 'unsigned char*'s around.
*/
-static ossl_inline unsigned char *PACKET_data(const PACKET *pkt)
+static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt)
{
return pkt->curr;
}
@@ -108,7 +106,8 @@ static ossl_inline unsigned char *PACKET_data(const PACKET *pkt)
* copy of the data so |buf| must be present for the whole time that the PACKET
* is being used.
*/
-__owur static ossl_inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf,
+__owur static ossl_inline int PACKET_buf_init(PACKET *pkt,
+ const unsigned char *buf,
size_t len)
{
/* Sanity check for negative values. */
@@ -325,7 +324,7 @@ __owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data)
* underlying buffer gets freed
*/
__owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt,
- unsigned char **data,
+ const unsigned char **data,
size_t len)
{
if (PACKET_remaining(pkt) < len)
@@ -343,7 +342,7 @@ __owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt,
* freed
*/
__owur static ossl_inline int PACKET_get_bytes(PACKET *pkt,
- unsigned char **data,
+ const unsigned char **data,
size_t len)
{
if (!PACKET_peek_bytes(pkt, data, len))
@@ -475,7 +474,7 @@ __owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt,
PACKET *subpkt)
{
unsigned int length;
- unsigned char *data;
+ const unsigned char *data;
PACKET tmp = *pkt;
if (!PACKET_get_1(&tmp, &length) ||
!PACKET_get_bytes(&tmp, &data, (size_t)length)) {
@@ -500,7 +499,7 @@ __owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt,
PACKET *subpkt)
{
unsigned int length;
- unsigned char *data;
+ const unsigned char *data;
PACKET tmp = *pkt;
if (!PACKET_get_net_2(&tmp, &length) ||
!PACKET_get_bytes(&tmp, &data, (size_t)length)) {
@@ -525,7 +524,7 @@ __owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt,
PACKET *subpkt)
{
unsigned long length;
- unsigned char *data;
+ const unsigned char *data;
PACKET tmp = *pkt;
if (!PACKET_get_net_3(&tmp, &length) ||
!PACKET_get_bytes(&tmp, &data, (size_t)length)) {