From: Ezra Peisach Date: Tue, 24 Apr 2001 17:05:34 +0000 (+0000) Subject: * client.c (main): Ensure that end of string is NULL terminated X-Git-Tag: krb5-1.3-alpha1~1559 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=09205548efb4adba70198f0324477b732bd8821f;p=krb5.git * client.c (main): Ensure that end of string is NULL terminated instead of assuming buffer initialized to 0. Include for memset prototype. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13187 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/rpc/unit-test/ChangeLog b/src/lib/rpc/unit-test/ChangeLog index bd91605d7..6ccd0c2fc 100644 --- a/src/lib/rpc/unit-test/ChangeLog +++ b/src/lib/rpc/unit-test/ChangeLog @@ -1,3 +1,9 @@ +2001-04-24 Ezra Peisach + + * client.c (main): Ensure that end of string is NULL terminated + instead of assuming buffer initialized to 0. Include + for memset prototype. + 2000-07-01 Ken Raeburn * Makefile.in (unit-test-body): Combine -tcp and -udp versions, diff --git a/src/lib/rpc/unit-test/client.c b/src/lib/rpc/unit-test/client.c index b0e831704..e2405cf14 100644 --- a/src/lib/rpc/unit-test/client.c +++ b/src/lib/rpc/unit-test/client.c @@ -5,6 +5,11 @@ * $Source$ * * $Log$ + * Revision 1.17 2001/04/24 17:05:34 epeisach + * * client.c (main): Ensure that end of string is NULL terminated + * instead of assuming buffer initialized to 0. Include + * for memset prototype. + * * Revision 1.16 1998/02/14 02:29:42 tlyu * * client.c: Update header locations. Rename of xdr_free. * @@ -95,6 +100,7 @@ static char *rcsid = "$Header$"; #endif #include +#include #include #include #include @@ -120,6 +126,13 @@ struct auth_gssapi_data { extern int auth_debug_gssapi; char *whoami; +static void usage() +{ + fprintf(stderr, "usage: %s {-t|-u} [-a] [-s num] [-m num] host service [count]\n", + whoami); + exit(1); +} + main(argc, argv) int argc; char **argv; @@ -177,8 +190,8 @@ main(argc, argv) switch (argc) { case 3: count = atoi(argv[2]); - if (count > BIG_BUF) { - fprintf(stderr, "Test count cannot exceed %d.\n", BIG_BUF); + if (count > BIG_BUF-1) { + fprintf(stderr, "Test count cannot exceed %d.\n", BIG_BUF-1); usage(); } case 2: @@ -312,7 +325,7 @@ main(argc, argv) * this last, since it takes a while.. */ echo_arg = buf; - memset(buf, 0, count); + memset(buf, 0, count+1); for (i = 0; i < count; i++) { echo_resp = rpc_test_echo_1(&echo_arg, clnt); if (echo_resp == NULL) { @@ -342,9 +355,3 @@ main(argc, argv) exit(0); } -usage() -{ - fprintf(stderr, "usage: %s {-t|-u} [-a] [-s num] [-m num] host service [count]\n", - whoami); - exit(1); -}