aboutsummaryrefslogtreecommitdiff
path: root/xdr.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-03-21 22:35:48 -0400
committerPaul Selkirk <paul@psgd.org>2016-03-21 22:37:53 -0400
commitcdaf07d30bd440cf3ee2f6615d044634734047bd (patch)
tree6086334b65da625dc782074064543c891dec1bfa /xdr.c
parent46793833737e925af47e57d99bd037226d1cb2c4 (diff)
stupid fixes
Diffstat (limited to 'xdr.c')
-rw-r--r--xdr.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/xdr.c b/xdr.c
index 2741752..42f0793 100644
--- a/xdr.c
+++ b/xdr.c
@@ -157,15 +157,6 @@ hal_error_t hal_xdr_decode_buffer_in_place(uint8_t **inbuf, const uint8_t * cons
return HAL_ERROR_IO_BAD_COUNT;
}
- /* user buffer is too small, update *len
- */
- if (*len < xdr_len) {
- *len = xdr_len;
- /* undo read of length */
- *inbuf = orig_inbuf;
- return HAL_ERROR_IO_BAD_COUNT;
- }
-
/* return a pointer to the string or opaque data */
*value = *inbuf;
*len = xdr_len;
@@ -183,9 +174,20 @@ hal_error_t hal_xdr_decode_buffer(uint8_t **inbuf, const uint8_t * const limit,
{
hal_error_t ret;
uint8_t *vptr;
+ uint8_t *orig_inbuf = *inbuf;
+ uint32_t xdr_len;
+
+ if ((ret = hal_xdr_decode_buffer_in_place(inbuf, limit, &vptr, &xdr_len)) == HAL_OK) {
+ if (*len < xdr_len) {
+ /* user buffer is too small, update *len */
+ *len = xdr_len;
+ /* undo read of length */
+ *inbuf = orig_inbuf;
+ return HAL_ERROR_IO_BAD_COUNT;
+ }
- if ((ret = hal_xdr_decode_buffer_in_place(inbuf, limit, &vptr, len)) == HAL_OK)
memcpy(value, vptr, *len);
+ }
return ret;
}