--- 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;
|