OSSP CVS Repository

ossp - Check-in [4273]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4273
Date: 2001-Aug-02 13:52:11 (local)
2001-Aug-02 11:52:11 (UTC)
User:simons
Branch:
Comment: xdr_decode_string() will no longer return the length of the decoded string. Use strlen() to determine that length or use xdr_(en|de)code_octetstream() to begin with.
Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xdr-string-empty.c      1.3->removed
ossp-pkg/xds/regression-tests/xdr-string.c      1.3 -> 1.4     7 inserted, 8 deleted
ossp-pkg/xds/xdr-decode-string.c      1.6->removed

ossp-pkg/xds/regression-tests/xdr-string-empty.c 1.3 -> 1.4

--- xdr-string-empty.c   2001/08/01 15:25:50     1.3
+++ xdr-string-empty.c   2001/08/02 11:52:12     1.4
@@ -37,7 +37,6 @@
 
     char   msg[] = "";
     char*  new_msg;
-    size_t new_msg_size;
 
     /* Encode the string as octet stream. Then erase the buffer and
        decode the string back, verifying that it hasn't changed. */
@@ -48,12 +47,12 @@
         printf("Failed to initialize XDS context.\n");
         return 1;
         }
-    if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK)
+    if (xds_register(xds, "string", &xdr_encode_string, NULL) != XDS_OK)
         {
         printf("Failed to register my encoding engines.\n");
         return 1;
         }
-    if (xds_encode(xds, "os", msg, 0) != XDS_OK)
+    if (xds_encode(xds, "string", msg, 0) != XDS_OK)
         {
         printf("xds_encode() failed.\n");
         return 1;
@@ -76,7 +75,7 @@
         printf("Failed to initialize XDS context.\n");
         return 1;
         }
-    if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK)
+    if (xds_register(xds, "string", &xdr_decode_string, NULL) != XDS_OK)
         {
         printf("Failed to register my decoding engines.\n");
         return 1;
@@ -86,21 +85,16 @@
         printf("xds_setbuffer() failed.\n");
         return 1;
         }
-    if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+    if (xds_decode(xds, "string", &new_msg) != XDS_OK)
         {
         printf("xds_decode() failed.\n");
         return 1;
         }
-    if (new_msg_size != 0)
+    if (strlen(new_msg) != 0)
         {
         printf("The size of the decoded message is wrong.\n");
         return 1;
         }
-    if (memcmp(msg, new_msg, new_msg_size) != 0)
-        {
-        printf("The decoded string is not correct.\n");
-        return 1;
-        }
     xds_destroy(xds);
     free(new_msg);
 


ossp-pkg/xds/regression-tests/xdr-string.c 1.3 -> 1.4

--- xdr-string.c 2001/08/01 15:25:50     1.3
+++ xdr-string.c 2001/08/02 11:52:12     1.4
@@ -37,7 +37,6 @@
 
     char   msg[] = "Hello World";
     char*  new_msg;
-    size_t new_msg_size;
 
     /* Encode the string as octet stream. Then erase the buffer and
        decode the string back, verifying that it hasn't changed. */
@@ -48,12 +47,12 @@
         printf("Failed to initialize XDS context.\n");
         return 1;
         }
-    if (xds_register(xds, "os", &xdr_encode_string, NULL) != XDS_OK)
+    if (xds_register(xds, "string", &xdr_encode_string, NULL) != XDS_OK)
         {
         printf("Failed to register my encoding engines.\n");
         return 1;
         }
-    if (xds_encode(xds, "os", msg) != XDS_OK)
+    if (xds_encode(xds, "string", msg) != XDS_OK)
         {
         printf("xds_encode() failed.\n");
         return 1;
@@ -76,7 +75,7 @@
         printf("Failed to initialize XDS context.\n");
         return 1;
         }
-    if (xds_register(xds, "os", &xdr_decode_string, NULL) != XDS_OK)
+    if (xds_register(xds, "string", &xdr_decode_string, NULL) != XDS_OK)
         {
         printf("Failed to register my decoding engines.\n");
         return 1;
@@ -86,17 +85,17 @@
         printf("xds_setbuffer() failed.\n");
         return 1;
         }
-    if (xds_decode(xds, "os", &new_msg, &new_msg_size) != XDS_OK)
+    if (xds_decode(xds, "string", &new_msg) != XDS_OK)
         {
         printf("xds_decode() failed.\n");
         return 1;
         }
-    if (new_msg_size != strlen(msg))
+    if (strlen(new_msg) != strlen(msg))
         {
-        printf("The size of the decoded message is wrong: %d.\n", new_msg_size);
+        printf("The size of the decoded message is wrong.\n");
         return 1;
         }
-    if (memcmp(msg, new_msg, new_msg_size) != 0)
+    if (memcmp(msg, new_msg, strlen(new_msg)) != 0)
         {
         printf("The decoded string is not correct.\n");
         return 1;


ossp-pkg/xds/xdr-decode-string.c 1.6 -> 1.7

--- xdr-decode-string.c  2001/08/02 08:10:13     1.6
+++ xdr-decode-string.c  2001/08/02 11:52:11     1.7
@@ -33,43 +33,41 @@
                       va_list* args)
     {
     char**  p;
-    size_t* p_len;
+    size_t  p_len;
     size_t  padding;
 
     xds_init_decoding_engine(4);
 
     p     = va_arg(*args, char**);
-    p_len = va_arg(*args, size_t*);
     xds_check_parameter(p != NULL);
-    xds_check_parameter(p_len != NULL);
 
     /* Read the size of the message. */
 
-    *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];
+    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. */
 
-    padding = (4 - (*p_len & 0x03)) & 0x03;
+    padding = (4 - (p_len & 0x03)) & 0x03;
 
     /* Do we have enough data?. */
 
-    *used_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. */
 
-    *p = (char*)malloc(*p_len + 1);
+    *p = (char*)malloc(p_len + 1);
     if (*p == NULL)
         return XDS_ERR_NO_MEM;
 
     /* Copy data into the buffer. */
 
-    memmove(*p, (xds_uint8_t*)buffer+4, *p_len);
-    ((xds_uint8_t*)buffer)[4+*p_len] = '\0';
+    memmove(*p, (xds_uint8_t*)buffer+4, p_len);
+    ((xds_uint8_t*)buffer)[4+p_len] = '\0';
 
     /* Done. */
 

CVSTrac 2.0.1