Blame SOURCES/net-snmp-5.9.1-python-usenumeric.patch

bc6b3f
From 8c1dad23301692799749d75a3c039b8ae7c07f8e Mon Sep 17 00:00:00 2001
bc6b3f
From: Bart Van Assche <bvanassche@acm.org>
bc6b3f
Date: Wed, 9 Jun 2021 14:19:46 -0700
bc6b3f
Subject: [PATCH] Python: Fix snmpwalk with UseNumeric=1
bc6b3f
bc6b3f
Fixes: c744be5ffed6 ("Python: Introduce build_python_varbind()")
bc6b3f
Fixes: https://github.com/net-snmp/net-snmp/issues/303
bc6b3f
---
bc6b3f
 python/netsnmp/client_intf.c | 9 ++++-----
bc6b3f
 1 file changed, 4 insertions(+), 5 deletions(-)
bc6b3f
bc6b3f
diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
bc6b3f
index e5e7372303..94da39fe34 100644
bc6b3f
--- a/python/netsnmp/client_intf.c
bc6b3f
+++ b/python/netsnmp/client_intf.c
bc6b3f
@@ -1316,7 +1316,7 @@ netsnmp_delete_session(PyObject *self, PyObject *args)
bc6b3f
 
bc6b3f
 static int build_python_varbind(PyObject *varbind, netsnmp_variable_list *vars,
bc6b3f
                                 int varlist_ind, int sprintval_flag, int *len,
bc6b3f
-                                char **str_buf)
bc6b3f
+                                char **str_buf, int getlabel_flag)
bc6b3f
 {
bc6b3f
     struct tree *tp;
bc6b3f
     int type;
bc6b3f
@@ -1326,7 +1326,6 @@ static int build_python_varbind(PyObject *varbind, netsnmp_variable_list *vars,
bc6b3f
     int buf_over = 0;
bc6b3f
     const char *tag;
bc6b3f
     const char *iid;
bc6b3f
-    int getlabel_flag = NO_FLAGS;
bc6b3f
 
bc6b3f
     if (!PyObject_HasAttrString(varbind, "tag"))
bc6b3f
         return TYPE_OTHER;
bc6b3f
@@ -1523,7 +1522,7 @@ netsnmp_get_or_getnext(PyObject *self, PyObject *args, int pdu_type,
bc6b3f
 
bc6b3f
       varbind = PySequence_GetItem(varlist, varlist_ind);
bc6b3f
       type = build_python_varbind(varbind, vars, varlist_ind, sprintval_flag,
bc6b3f
-                                  &len, &str_buf);
bc6b3f
+                                  &len, &str_buf, getlabel_flag);
bc6b3f
       if (type != TYPE_OTHER) {
bc6b3f
           /* save in return tuple as well */
bc6b3f
           if ((type == SNMP_ENDOFMIBVIEW) ||
bc6b3f
@@ -1832,7 +1831,7 @@ netsnmp_walk(PyObject *self, PyObject *args)
bc6b3f
 
bc6b3f
               varbind = py_netsnmp_construct_varbind();
bc6b3f
               if (varbind && build_python_varbind(varbind, vars, varlist_ind,
bc6b3f
-                                       sprintval_flag, &len, &str_buf) !=
bc6b3f
+                                       sprintval_flag, &len, &str_buf, getlabel_flag) !=
bc6b3f
                   TYPE_OTHER) {
bc6b3f
                   const int hex = is_hex(str_buf, len);
bc6b3f
 
bc6b3f
@@ -2055,7 +2054,7 @@ netsnmp_getbulk(PyObject *self, PyObject *args)
bc6b3f
 
bc6b3f
 	  varbind = py_netsnmp_construct_varbind();
bc6b3f
           if (varbind && build_python_varbind(varbind, vars, varbind_ind,
bc6b3f
-                              sprintval_flag, &len, &str_buf) != TYPE_OTHER) {
bc6b3f
+                              sprintval_flag, &len, &str_buf, getlabel_flag) != TYPE_OTHER) {
bc6b3f
             const int hex = is_hex(str_buf, len);
bc6b3f
 
bc6b3f
             /* push varbind onto varbinds */
bc6b3f