Add an ability to find out the current write location from a WPACKET
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
parent
c53f7355b9
commit
3171bad66e
2 changed files with 14 additions and 2 deletions
|
@ -62,7 +62,8 @@ int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
|
||||||
if (BUF_MEM_grow(pkt->buf, newlen) == 0)
|
if (BUF_MEM_grow(pkt->buf, newlen) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*allocbytes = GETBUF(pkt) + pkt->curr;
|
if (allocbytes != NULL)
|
||||||
|
*allocbytes = GETBUF(pkt) + pkt->curr;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -376,6 +377,11 @@ int WPACKET_get_length(WPACKET *pkt, size_t *len)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char *WPACKET_get_curr(WPACKET *pkt)
|
||||||
|
{
|
||||||
|
return GETBUF(pkt) + pkt->curr;
|
||||||
|
}
|
||||||
|
|
||||||
void WPACKET_cleanup(WPACKET *pkt)
|
void WPACKET_cleanup(WPACKET *pkt)
|
||||||
{
|
{
|
||||||
WPACKET_SUB *sub, *parent;
|
WPACKET_SUB *sub, *parent;
|
||||||
|
|
|
@ -728,7 +728,7 @@ int WPACKET_start_sub_packet(WPACKET *pkt);
|
||||||
/*
|
/*
|
||||||
* Allocate bytes in the WPACKET for the output. This reserves the bytes
|
* Allocate bytes in the WPACKET for the output. This reserves the bytes
|
||||||
* and counts them as "written", but doesn't actually do the writing. A pointer
|
* and counts them as "written", but doesn't actually do the writing. A pointer
|
||||||
* to the allocated bytes is stored in |*allocbytes|.
|
* to the allocated bytes is stored in |*allocbytes|. |allocbytes| may be NULL.
|
||||||
* WARNING: the allocated bytes must be filled in immediately, without further
|
* WARNING: the allocated bytes must be filled in immediately, without further
|
||||||
* WPACKET_* calls. If not then the underlying buffer may be realloc'd and
|
* WPACKET_* calls. If not then the underlying buffer may be realloc'd and
|
||||||
* change its location.
|
* change its location.
|
||||||
|
@ -854,6 +854,12 @@ int WPACKET_get_total_written(WPACKET *pkt, size_t *written);
|
||||||
*/
|
*/
|
||||||
int WPACKET_get_length(WPACKET *pkt, size_t *len);
|
int WPACKET_get_length(WPACKET *pkt, size_t *len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a pointer to the current write location, but does not allocate any
|
||||||
|
* bytes.
|
||||||
|
*/
|
||||||
|
unsigned char *WPACKET_get_curr(WPACKET *pkt);
|
||||||
|
|
||||||
/* Release resources in a WPACKET if a failure has occurred. */
|
/* Release resources in a WPACKET if a failure has occurred. */
|
||||||
void WPACKET_cleanup(WPACKET *pkt);
|
void WPACKET_cleanup(WPACKET *pkt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue