Hi,

While testing snmp(1), I found the following weird behaviour regarding error
message:

$ snmp get 192.168.1.5 sysDescr.0 sysUpTime.0
sysDescr.0 = STRING: TOSHIBA e-STUDIO3505AC
sysUpTime.0 = Timeticks: (55587200) 6 day 10:24:32.00

$ snmp get 192.168.1.5 sysDescr.0 sysUpTime.0 xxx
snmp: sysDescr.0: Unknown object identifier

The first command returns valid values. For the second, where the third oid is
invalid, the error message speak about the first oid.

The following diff corrects the error message by picking the right argv element.

Comments or OK ?
-- 
Sebastien Marie

Index: snmpc.c
===================================================================
RCS file: /cvs/src/usr.bin/snmp/snmpc.c,v
retrieving revision 1.11
diff -u -p -r1.11 snmpc.c
--- snmpc.c     18 Sep 2019 09:54:36 -0000      1.11
+++ snmpc.c     3 Oct 2019 06:50:19 -0000
@@ -496,7 +496,7 @@ snmpc_get(int argc, char *argv[])
                err(1, "malloc");
        for (i = 0; i < argc; i++) {
                if (smi_string2oid(argv[i], &oid[i]) == -1)
-                       errx(1, "%s: Unknown object identifier", argv[0]);
+                       errx(1, "%s: Unknown object identifier", argv[i]);
        }
        if (strcmp(snmp_app->name, "getnext") == 0) {
                if ((pdu = snmp_getnext(agent, oid, argc)) == NULL)

Reply via email to