From 3108e3605cbf9a0cd0becaeeab9d976f3a7f298c Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 16 May 2008 16:09:34 -0700 Subject: [PATCH] snmpapi: Test and correct SnmpUtilOidNCmp when count is less than Oid length. --- dlls/snmpapi/main.c | 1 + dlls/snmpapi/tests/util.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/dlls/snmpapi/main.c b/dlls/snmpapi/main.c index 0e60d88e7fe..9e14a194876 100644 --- a/dlls/snmpapi/main.c +++ b/dlls/snmpapi/main.c @@ -356,6 +356,7 @@ INT WINAPI SnmpUtilOidNCmp(AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2, if (oid1->ids[i] > oid2->ids[i]) return 1; if (oid1->ids[i] < oid2->ids[i]) return -1; } + if (i == count) return 0; if (oid1->idLength < oid2->idLength) return -1; if (oid1->idLength > oid2->idLength) return 1; return 0; diff --git a/dlls/snmpapi/tests/util.c b/dlls/snmpapi/tests/util.c index 3d513bd9349..428040d4066 100644 --- a/dlls/snmpapi/tests/util.c +++ b/dlls/snmpapi/tests/util.c @@ -330,6 +330,11 @@ static void test_SnmpUtilOidNCmp(void) ok(ret == 1, "SnmpUtilOidNCmp failed: %d\n", ret); ret = SnmpUtilOidNCmp(&oid1, &oid2, 4); ok(ret == -1, "SnmpUtilOidNCmp failed: %d\n", ret); + + ret = SnmpUtilOidNCmp(&oid1, &oid2, 2); + ok(!ret, "SnmpUtilOidNCmp failed: %d\n", ret); + ret = SnmpUtilOidNCmp(&oid2, &oid1, 2); + ok(!ret, "SnmpUtilOidNCmp failed: %d\n", ret); } static void test_SnmpUtilOidCmp(void)