ossp-pkg/xds/xdr-decode-string.c 1.4.2.2 -> 1.4.2.3
--- xdr-decode-string.c 2001/08/01 13:26:29 1.4.2.2
+++ xdr-decode-string.c 2001/08/01 14:38:07 1.4.2.3
@@ -36,32 +36,19 @@
size_t* p_len;
size_t padding;
- /* Consistency checks. */
-
- xds_check_parameter(xds != NULL);
- xds_check_parameter(buffer != NULL);
- xds_check_parameter(buffer_size != 0);
- xds_check_parameter(used_buffer_size != NULL);
- xds_check_parameter(args != NULL);
-
- /* Get pointers from the stack. */
+ xds_init_decoding_engine(4);
p = va_arg(*args, char**);
p_len = va_arg(*args, size_t*);
- assert(p != NULL);
- assert(p_len != NULL);
+ xds_check_parameter(p != NULL);
+ xds_check_parameter(p_len != NULL);
/* Read the size of the message. */
- if (buffer_size >= 4)
- {
- *p_len = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
- *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
- *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
- *p_len += ((xds_uint8_t*)buffer)[3];
- }
- else
- return XDS_ERR_UNDERFLOW;
+ *p_len = ((xds_uint8_t*)buffer)[0]; *p_len = *p_len << 8;
+ *p_len += ((xds_uint8_t*)buffer)[1]; *p_len = *p_len << 8;
+ *p_len += ((xds_uint8_t*)buffer)[2]; *p_len = *p_len << 8;
+ *p_len += ((xds_uint8_t*)buffer)[3];
/* Calculate padding. */
@@ -69,10 +56,9 @@
/* Do we have enough data?. */
- if (buffer_size < 4 + *p_len + padding)
+ *used_buffer_size = 4 + *p_len + padding;
+ if (buffer_size < *used_buffer_size)
return XDS_ERR_UNDERFLOW;
- else
- *used_buffer_size = 4 + *p_len + padding;
/* Allocate buffer for the data. */
|
|