Refreshing Python filters?
David Hláčik
david at hlacik.eu
Sun Jun 8 14:25:01 UTC 2008
Ou, when i will patch it with
ftp://ftp.isc.org/isc/inn/snapshots/inn-STABLE-20080608.tar.gz which
is lastest snapshot i found,
after putting your patch to file "patch" to directory INN , and
applying patch -p0<patch i will get :
-bash-3.1# patch -p0 < patch
patching file nnrpd/python.c
patch: **** malformed patch at line 6: PY_access(char* file, struct
vector *access_vec, char *Username)
On Sun, Jun 8, 2008 at 3:59 PM, Julien ÉLIE <julien at trigofacile.com> wrote:
> Hi David,
>
> [A nasty strcat... But I do not understand why we cannot free(skey) or
> free(svalue)
> with that. Does someone have an explanation?
> I switched to strlcpy and strlcat -- please tell me if my code is not
> optimal.]
>
>
>> Wow , so my chances to realize it until tomorrow are definitely gone :(
>
> No they aren't :-)
>
> Could you please try this patch?
> It seems to work well on the INN I use.
>
>
> Index: nnrpd/python.c
> ===================================================================
> --- nnrpd/python.c (révision 7829)
> +++ nnrpd/python.c (copie de travail)
> @@ -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,7 @@
>
> /* 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 +311,15 @@
> 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);
>
>
> --
> Julien ÉLIE
>
> « Je vais t'apprendre à chasser... Nous commencerons par les marcassins,
> et puis ensuite, nous passerons aux patrouilles romaines, et enfin
> aux sangliers ! » (Astérix)
>
>
More information about the inn-workers
mailing list