OSSP CVS Repository

ossp - Difference in ossp-pkg/xds/regression-tests/xds-encode.c versions 1.5 and 1.5.2.1
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/xds/regression-tests/xds-encode.c 1.5 -> 1.5.2.1

--- xds-encode.c 2001/07/18 17:37:49     1.5
+++ xds-encode.c 2001/08/01 11:27:20     1.5.2.1
@@ -29,7 +29,9 @@
 #include <string.h>
 #include "../internal.h"
 
-static int dummy_engine(xds_t* xds, void* engine_context, void* buffer, size_t buffer_size, va_list* args)
+static int dummy_engine(xds_t* xds, void* engine_context,
+                        void* buffer, size_t buffer_size, size_t* used_buffer_size,
+                        va_list* args)
     {
     if (xds == NULL)
         {
@@ -48,7 +50,12 @@
         }
     if (buffer_size == 0)
         {
-        printf("Buffer size passed to engine is zero!\n");
+        printf("buffer_size passed to engine is zero!\n");
+        exit(1);
+        }
+    if (used_buffer_size == NULL)
+        {
+        printf("used_buffer_size pointer passed to engine is NULL!\n");
         exit(1);
         }
     if (args == NULL)
@@ -56,8 +63,13 @@
         printf("args pointer passed to engine is NULL!\n");
         exit(1);
         }
-    strncpy(buffer, "Hallo ", buffer_size);
-    return 6;
+    if (buffer_size < 6)
+        return XDS_ERR_OVERFLOW;
+    else
+        *used_buffer_size = 6;
+
+    memmove(buffer, "Hallo ", 6);
+    return XDS_OK;
     }
 
 int main()
@@ -88,7 +100,7 @@
 
     if (xds_encode(xds, "int:text    double double float") != XDS_OK)
         {
-        printf("xds_encode() failed!");
+        printf("xds_encode() failed!\n");
         return 1;
         }
     if (strcmp(xds->buffer, "Hallo Hallo Hallo Hallo Hallo ") != 0)

CVSTrac 2.0.1