INN commit: trunk (CONTRIBUTORS nnrpd/python.c)
INN Commit
Russ_Allbery at isc.org
Mon Jun 9 18:14:25 UTC 2008
Date: Monday, June 9, 2008 @ 11:14:25
Author: iulius
Revision: 7868
Fix a segfault when generating access groups with embedded Python
filters for nnrpd.
Thanks to David Hlacik for the bug report.
Modified:
trunk/CONTRIBUTORS
trunk/nnrpd/python.c
----------------+
CONTRIBUTORS | 3 ++-
nnrpd/python.c | 26 ++++++++++++--------------
2 files changed, 14 insertions(+), 15 deletions(-)
Modified: CONTRIBUTORS
===================================================================
--- CONTRIBUTORS 2008-06-09 18:10:32 UTC (rev 7867)
+++ CONTRIBUTORS 2008-06-09 18:14:25 UTC (rev 7868)
@@ -267,4 +267,5 @@
Ray Miller, Andreas M. Kirchwitz, Andrey Yakovlev, Christoph Biedl,
Kai Gallasch, Ollivier Robert, Ivan Shmakov, Kachun Lee, Kirill Berezin,
D. Stussy, Alan Schwartz, Shalon Wood, Nick Couchman, Jakub Bogusz,
-J. Thomas Halliley, Matija Nalis, Geraint A. Edwards, Alexander Bartolich
+J. Thomas Halliley, Matija Nalis, Geraint A. Edwards, Alexander Bartolich,
+David Hlacik
Modified: nnrpd/python.c
===================================================================
--- nnrpd/python.c 2008-06-09 18:10:32 UTC (rev 7867)
+++ nnrpd/python.c 2008-06-09 18:14:25 UTC (rev 7868)
@@ -232,7 +232,7 @@
PY_access(char* file, struct vector *access_vec, char *Username)
{
PyObject *result, *key, *value, *proc;
- char *skey, *svalue, *temp;
+ char *buffer;
int authnum;
int i;
@@ -298,6 +298,8 @@
/* store dict values in proper format in access vector */
i = 0;
+ buffer = xmalloc(BIG_BUFFER);
+
while(PyDict_Next(result, &i, &key, &value)) {
if (!PyString_Check(key)) {
syslog(L_ERROR, "python access method return dictionary key %i not a string", i);
@@ -310,20 +312,16 @@
ExitWithStats(1, false);
}
- temp = PyString_AsString(key);
- skey = xstrdup(temp);
-
- temp = PyString_AsString(value);
- svalue = xstrdup(temp);
-
- skey = strcat(skey, ": \"");
- skey = strcat(skey, svalue);
- skey = strcat(skey, "\"\n");
- vector_add(access_vec, skey);
-
- free(skey);
- free(svalue);
+ strlcpy(buffer, PyString_AsString(key), BIG_BUFFER);
+ strlcat(buffer, ": \"", BIG_BUFFER);
+ strlcat(buffer, PyString_AsString(value), BIG_BUFFER);
+ strlcat(buffer, "\"\n", BIG_BUFFER);
+
+ vector_add(access_vec, xstrdup(buffer));
+ syslog(L_ERROR, "buffer %s", xstrdup(buffer));
}
+
+ free(buffer);
/* Clean up the dictionary object */
PyDict_Clear(PYauthinfo);
More information about the inn-committers
mailing list