OSSP CVS Repository

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

Check-in Number: 4290
Date: 2001-Aug-08 11:19:34 (local)
2001-Aug-08 09:19:34 (UTC)
User:simons
Branch:
Comment: Use sizeof() rather than strlen() to determine the length of fixed strings in the program.
Tickets:
Inspections:
Files:
ossp-pkg/xds/regression-tests/xdr-string.c      1.4->removed
ossp-pkg/xds/regression-tests/xds-decode.c      1.4->removed

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

--- xdr-string.c 2001/08/02 11:52:12     1.4
+++ xdr-string.c 2001/08/08 09:19:34     1.5
@@ -90,12 +90,12 @@
         printf("xds_decode() failed.\n");
         return 1;
         }
-    if (strlen(new_msg) != strlen(msg))
+    if (strlen(new_msg) != sizeof(msg)-1)
         {
         printf("The size of the decoded message is wrong.\n");
         return 1;
         }
-    if (memcmp(msg, new_msg, strlen(new_msg)) != 0)
+    if (memcmp(msg, new_msg, sizeof(msg)-1) != 0)
         {
         printf("The decoded string is not correct.\n");
         return 1;


ossp-pkg/xds/regression-tests/xds-decode.c 1.4 -> 1.5

--- xds-decode.c 2001/08/01 15:25:50     1.4
+++ xds-decode.c 2001/08/08 09:19:34     1.5
@@ -102,7 +102,7 @@
     /* Decode the buffer and have the callback report when something
        is wrong. */
 
-    if (xds_setbuffer(xds, XDS_LOAN, buffer, strlen(buffer)) != XDS_OK)
+    if (xds_setbuffer(xds, XDS_LOAN, buffer, sizeof(buffer)-1) != XDS_OK)
         {
         printf("xds_decode() failed!");
         return 1;

CVSTrac 2.0.1