snmpapi: Test and correct SnmpUtilOidNCmp when count is less than Oid length.

This commit is contained in:
Juan Lang 2008-05-16 16:09:34 -07:00 committed by Alexandre Julliard
parent a96e118ddb
commit 3108e3605c
2 changed files with 6 additions and 0 deletions

View File

@ -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 (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;
if (oid1->idLength > oid2->idLength) return 1; if (oid1->idLength > oid2->idLength) return 1;
return 0; return 0;

View File

@ -330,6 +330,11 @@ static void test_SnmpUtilOidNCmp(void)
ok(ret == 1, "SnmpUtilOidNCmp failed: %d\n", ret); ok(ret == 1, "SnmpUtilOidNCmp failed: %d\n", ret);
ret = SnmpUtilOidNCmp(&oid1, &oid2, 4); ret = SnmpUtilOidNCmp(&oid1, &oid2, 4);
ok(ret == -1, "SnmpUtilOidNCmp failed: %d\n", ret); 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) static void test_SnmpUtilOidCmp(void)