Rob Shearman : rpcrt4: Fix buffer overflow in UUID tests.
Alexandre Julliard
julliard at winehq.org
Mon Jan 26 10:13:54 CST 2009
Module: wine
Branch: master
Commit: 2ec1e4a3935811602394531260448e24b5f8d4b1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ec1e4a3935811602394531260448e24b5f8d4b1
Author: Rob Shearman <robertshearman at gmail.com>
Date: Sun Jan 25 17:07:20 2009 +0000
rpcrt4: Fix buffer overflow in UUID tests.
---
dlls/rpcrt4/tests/rpc.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index e50dcdc..bf538e4 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -764,9 +764,9 @@ static void test_RpcStringBindingFromBinding(void)
ok(status == RPC_S_OK, "RpcBindingFree failed with error %u\n", status);
}
-static char *printGuid(char *buf, const UUID *guid)
+static char *printGuid(char *buf, int size, const UUID *guid)
{
- sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
+ snprintf(buf, size, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1],
guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5],
guid->Data4[6], guid->Data4[7]);
@@ -792,8 +792,8 @@ static void test_UuidCreate(void)
int i;
char buf[39];
- memcpy(&and, &guid, sizeof(guid));
- memcpy(&or, &guid, sizeof(guid));
+ and = guid;
+ or = guid;
/* Generate a bunch of UUIDs and mask them. By the end, we expect
* every randomly generated bit to have been zero at least once,
* resulting in no bits set in the and mask except those which are not
@@ -814,9 +814,9 @@ static void test_UuidCreate(void)
*dst |= *src;
}
ok(UuidEqual(&and, &v4and, &rslt),
- "unexpected bits set in V4 UUID: %s\n", printGuid(buf, &and));
+ "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &and));
ok(UuidEqual(&or, &v4or, &rslt),
- "unexpected bits set in V4 UUID: %s\n", printGuid(buf, &or));
+ "unexpected bits set in V4 UUID: %s\n", printGuid(buf, sizeof(buf), &or));
}
else
{
More information about the wine-cvs
mailing list