Update of /cvsroot/toxine/toxine/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16354
Modified Files:
parse.c
Log Message:
avoid segfaulting with too long command line (like in repeat mode).
Index: parse.c
===================================================================
RCS file: /cvsroot/toxine/toxine/src/parse.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- parse.c 19 May 2004 21:23:38 -0000 1.9
+++ parse.c 24 May 2004 20:53:25 -0000 1.10
@@ -33,10 +33,8 @@
* Push first command in remain queue to current command.
*/
static void toxine_parse_destock_remain(toxine_t *tox) {
- char *p, *pp, *c;
- char *pbuf;
- char commandline[BUFSIZ];
- char remaining[BUFSIZ];
+ char *p;
+
/*
* Remain and line are already filled, perhaps a forced command line
@@ -56,9 +54,16 @@
if(tox->command.remain &&
((tox->command.line == NULL) ||
((tox->command.line != NULL) && (strlen(tox->command.line) == 0)))) {
+ char *pbuf, *pp, *c, *commandline, *remaining;
+ int len;
- memset(&commandline, 0, sizeof(commandline));
- memset(&remaining, 0, sizeof(remaining));
+ if(tox->command.line && (strlen(tox->command.line) > strlen(tox->command.remain)))
+ len = strlen(tox->command.line);
+ else
+ len = strlen(tox->command.remain);
+
+ commandline = (char *) xine_xmalloc(sizeof(char) * (len + 1));
+ remaining = (char *) xine_xmalloc(sizeof(char) * (len + 1));
if((p = strchr(tox->command.remain, ';')) && (*(p - 1) != '\\')) {
@@ -122,6 +127,9 @@
toxine_free(tox->command.remain);
}
+
+ toxine_free(commandline);
+ toxine_free(remaining);
}
}
|