summaryrefslogtreecommitdiff
path: root/svdrp.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-11-05 11:21:38 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2005-11-05 11:21:38 +0100
commit9607fd33a061530b3e26e2ffae14e87548b016ba (patch)
treea5a4ef45553f9c87e4dba63be285823b819ce009 /svdrp.c
parent92af12daac8a33db8be0b33335bd79330ced9463 (diff)
downloadvdr-9607fd33a061530b3e26e2ffae14e87548b016ba.tar.gz
vdr-9607fd33a061530b3e26e2ffae14e87548b016ba.tar.bz2
cSVDRP now dynamically allocates its command buffer
Diffstat (limited to 'svdrp.c')
-rw-r--r--svdrp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/svdrp.c b/svdrp.c
index cc5df706..8e09d41c 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
- * $Id: svdrp.c 1.82 2005/09/25 10:36:59 kls Exp $
+ * $Id: svdrp.c 1.83 2005/11/05 11:21:38 kls Exp $
*/
#include "svdrp.h"
@@ -361,6 +361,8 @@ cSVDRP::cSVDRP(int Port)
{
PUTEhandler = NULL;
numChars = 0;
+ length = BUFSIZ;
+ cmdLine = MALLOC(char, length);
message = NULL;
lastActivity = 0;
isyslog("SVDRP listening on port %d", Port);
@@ -370,6 +372,7 @@ cSVDRP::~cSVDRP()
{
Close();
free(message);
+ free(cmdLine);
}
void cSVDRP::Close(bool Timeout)
@@ -1442,6 +1445,11 @@ bool cSVDRP::Process(void)
// showtime!
Execute(cmdLine);
numChars = 0;
+ if (length > BUFSIZ) {
+ free(cmdLine); // let's not tie up too much memory
+ length = BUFSIZ;
+ cmdLine = MALLOC(char, length);
+ }
}
else if (c == 0x04 && numChars == 0) {
// end of file (only at beginning of line)
@@ -1455,15 +1463,14 @@ bool cSVDRP::Process(void)
else if (c <= 0x03 || c == 0x0D) {
// ignore control characters
}
- else if (numChars < sizeof(cmdLine) - 1) {
+ else {
+ if (numChars >= length - 1) {
+ length += BUFSIZ;
+ cmdLine = (char *)realloc(cmdLine, length);
+ }
cmdLine[numChars++] = c;
cmdLine[numChars] = 0;
}
- else {
- Reply(501, "Command line too long");
- esyslog("SVDRP: command line too long: '%s'", cmdLine);
- numChars = 0;
- }
lastActivity = time(NULL);
}
else if (r < 0) {