INN commit: branches/2.4/nnrpd (python.c)
INN Commit
Russ_Allbery at isc.org
Mon Jun 9 18:16:29 UTC 2008
Date: Monday, June 9, 2008 @ 11:16:29
Author: iulius
Revision: 7869
Fix a segfault when generating access groups with embedded Python
filters for nnrpd.
Thanks to David Hlacik for the bug report.
Modified:
branches/2.4/nnrpd/python.c
----------+
python.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
Modified: python.c
===================================================================
--- python.c 2008-06-09 18:14:25 UTC (rev 7868)
+++ python.c 2008-06-09 18:16:29 UTC (rev 7869)
@@ -225,7 +225,7 @@
*/
void 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;
@@ -291,6 +291,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);
@@ -302,22 +304,17 @@
Reply("%d Internal Error (7). Goodbye\r\n", NNTP_ACCESS_VAL);
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));
}
-
+
+ free(buffer);
+
/* Clean up the dictionary object */
PyDict_Clear(PYauthinfo);
/* Clean up dictionary items */
More information about the inn-committers
mailing list