Menu

#1356 Fix for bug 2823

backport-needed
open
None
5
2018-05-07
2018-04-02
Ian Bruene
No

I adapted the previous patch to work regardless on the value of verbose. Also bug 2823 is about the get() function, but the patch is for getnext(). Both functions have the issue and this patch covers both of them.

diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
index 2adf20836..2b21fed50 100644
--- a/python/netsnmp/client_intf.c
+++ b/python/netsnmp/client_intf.c
@@ -1341,6 +1341,13 @@ netsnmp_get(PyObject *self, PyObject *args)

     if (varlist) {
       PyObject *varlist_iter = PyObject_GetIter(varlist);
+      if (varlist_iter == NULL) {
+        if (verbose) {
+          printf("error: can't get iterator for varlist");
+        }
+          snmp_free_pdu(pdu);
+          goto done;
+      }

       while (varlist_iter && (varbind = PyIter_Next(varlist_iter))) {
        if (py_netsnmp_attr_string(varbind, "tag", &tag, NULL) < 0 ||
@@ -1559,6 +1566,13 @@ netsnmp_getnext(PyObject *self, PyObject *args)

     if (varlist) {
       PyObject *varlist_iter = PyObject_GetIter(varlist);
+      if (varlist_iter == NULL) {
+        if (verbose) {
+          printf("error: can't get iterator for varlist");
+        }
+          snmp_free_pdu(pdu);
+          goto done;
+      }

       while (varlist_iter && (varbind = PyIter_Next(varlist_iter))) {
        if (py_netsnmp_attr_string(varbind, "tag", &tag, NULL) < 0 ||

Discussion

  • Bart Van Assche

    Bart Van Assche - 2018-05-06

    If you are using a Net-SNMP version older than v5.7, please upgrade to v5.7.

     
  • Bart Van Assche

    Bart Van Assche - 2018-05-06
    • status: open --> closed
     
  • Ian Bruene

    Ian Bruene - 2018-05-06

    The patch was against the current HEAD when I made it.

     
  • Ian Bruene

    Ian Bruene - 2018-05-06

    Just tested, I can confirm that this bug is still present in the current HEAD.

     
  • Bart Van Assche

    Bart Van Assche - 2018-05-07
    • status: closed --> open
    • assigned_to: bart
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.