OSSP CVS Repository

ossp - Difference in ossp-pkg/xds/xdr-decode-string.c versions 1.4 and 1.5
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/xds/xdr-decode-string.c 1.4 -> 1.5

--- xdr-decode-string.c  2001/07/23 15:33:42     1.4
+++ xdr-decode-string.c  2001/08/01 15:25:47     1.5
@@ -26,42 +26,29 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "internal.h"
 
-int xdr_decode_string(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+int xdr_decode_string(xds_t* xds, void* engine_context,
+                      void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                      va_list* args)
     {
     char**  p;
     size_t* p_len;
     size_t  padding;
 
-    /* Consistency checks. */
-
-    assert(xds != NULL);
-    assert(buffer != NULL);
-    assert(buffer_size != 0);
-    assert(args != NULL);
-    if (xds == NULL || buffer == NULL || buffer_size == 0 || args == NULL)
-        return XDS_ERR_INVALID_ARG;
-
-    /* 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,7 +56,8 @@
 
     /* 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;
 
     /* Allocate buffer for the data. */
@@ -85,5 +73,5 @@
 
     /* Done. */
 
-    return 4 + *p_len + padding;
+    return XDS_OK;
     }

CVSTrac 2.0.1