OSSP CVS Repository

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

Check-in Number: 4262
Date: 2001-Aug-01 14:06:11 (local)
2001-Aug-01 12:06:11 (UTC)
User:simons
Branch:callback-semantic-rewrite
Comment: - Rewrote callback for the new semantics.

- Use memcmp() instead of strcmp() because we can't rely on trailing zero bytes.

Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xds-getbuffer.c      1.4.2.1->removed

ossp-pkg/xds/regression-tests/xds-getbuffer.c 1.4.2.1 -> 1.4.2.2

--- xds-getbuffer.c      2001/08/01 11:27:20     1.4.2.1
+++ xds-getbuffer.c      2001/08/01 12:06:11     1.4.2.2
@@ -33,8 +33,13 @@
                         void* buffer, size_t buffer_size, size_t* used_buffer_size,
                         va_list* args)
     {
-    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()
@@ -87,8 +92,8 @@
         printf("xds_getbuffer() failed for the second buffer!\n");
         return 1;
         }
-    if ((strcmp(old, "Hallo!Hallo!") != 0 || old_len != 12) &&
-        (strcmp(new, "Hallo!") != 0 || new_len != 6))
+    if ((memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12) &&
+        (memcmp(new, "Hallo!", 6) != 0 || new_len != 6))
         {
         printf("xds_encode() did not yield the expected result.\n");
         return 1;
@@ -110,7 +115,7 @@
         printf("xds_getbuffer() failed for the first buffer!\n");
         return 1;
         }
-    if (strcmp(old, "Hallo!Hallo!") != 0 || old_len != 12)
+    if (memcmp(old, "Hallo!Hallo!", 12) != 0 || old_len != 12)
         {
         printf("xds_encode() did not yield the expected result.\n");
         return 1;
@@ -130,7 +135,7 @@
         printf("xds_encode() allocated a new buffer even though we used XDS_LOAN.\n");
         return 1;
         }
-    if (strcmp(new, "Hallo!") != 0 || new_len != 6)
+    if (memcmp(new, "Hallo!", 6) != 0 || new_len != 6)
         {
         printf("xds_encode() did not yield the expected result.\n");
         return 1;

CVSTrac 2.0.1