mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	Made the input buffer in cSVDRPClient dynamic
This commit is contained in:
		
							
								
								
									
										1
									
								
								HISTORY
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								HISTORY
									
									
									
									
									
								
							@@ -9310,3 +9310,4 @@ Video Disk Recorder Revision History
 | 
				
			|||||||
- Commented out the logging in cMarks::Align(), to avoid log entries in case of editing
 | 
					- Commented out the logging in cMarks::Align(), to avoid log entries in case of editing
 | 
				
			||||||
  marks that are not generated by VDR itself, and thus may be a little off (suggested by
 | 
					  marks that are not generated by VDR itself, and thus may be a little off (suggested by
 | 
				
			||||||
  J<>rg Wendel). You can activate this line again for debugging if necessary.
 | 
					  J<>rg Wendel). You can activate this line again for debugging if necessary.
 | 
				
			||||||
 | 
					- Made the input buffer in cSVDRPClient dynamic.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								svdrp.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								svdrp.c
									
									
									
									
									
								
							@@ -10,7 +10,7 @@
 | 
				
			|||||||
 * and interact with the Video Disk Recorder - or write a full featured
 | 
					 * and interact with the Video Disk Recorder - or write a full featured
 | 
				
			||||||
 * graphical interface that sits on top of an SVDRP connection.
 | 
					 * graphical interface that sits on top of an SVDRP connection.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $Id: svdrp.c 4.35 2018/03/17 13:00:19 kls Exp $
 | 
					 * $Id: svdrp.c 4.36 2018/03/18 10:43:53 kls Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "svdrp.h"
 | 
					#include "svdrp.h"
 | 
				
			||||||
@@ -318,6 +318,8 @@ private:
 | 
				
			|||||||
  cIpAddress serverIpAddress;
 | 
					  cIpAddress serverIpAddress;
 | 
				
			||||||
  cSocket socket;
 | 
					  cSocket socket;
 | 
				
			||||||
  cString serverName;
 | 
					  cString serverName;
 | 
				
			||||||
 | 
					  int length;
 | 
				
			||||||
 | 
					  char *input;
 | 
				
			||||||
  int timeout;
 | 
					  int timeout;
 | 
				
			||||||
  cTimeMs pingTime;
 | 
					  cTimeMs pingTime;
 | 
				
			||||||
  cFile file;
 | 
					  cFile file;
 | 
				
			||||||
@@ -346,6 +348,8 @@ cSVDRPClient::cSVDRPClient(const char *Address, int Port, const char *ServerName
 | 
				
			|||||||
,socket(Port, true)
 | 
					,socket(Port, true)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  serverName = ServerName;
 | 
					  serverName = ServerName;
 | 
				
			||||||
 | 
					  length = BUFSIZ;
 | 
				
			||||||
 | 
					  input = MALLOC(char, length);
 | 
				
			||||||
  timeout = Timeout * 1000 * 9 / 10; // ping after 90% of timeout
 | 
					  timeout = Timeout * 1000 * 9 / 10; // ping after 90% of timeout
 | 
				
			||||||
  pingTime.Set(timeout);
 | 
					  pingTime.Set(timeout);
 | 
				
			||||||
  fetchFlags = sffNone;
 | 
					  fetchFlags = sffNone;
 | 
				
			||||||
@@ -363,6 +367,7 @@ cSVDRPClient::cSVDRPClient(const char *Address, int Port, const char *ServerName
 | 
				
			|||||||
cSVDRPClient::~cSVDRPClient()
 | 
					cSVDRPClient::~cSVDRPClient()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  Close();
 | 
					  Close();
 | 
				
			||||||
 | 
					  free(input);
 | 
				
			||||||
  dsyslog("SVDRP %s > %s client destroyed for '%s'", Setup.SVDRPHostName, serverIpAddress.Connection(), *serverName);
 | 
					  dsyslog("SVDRP %s > %s client destroyed for '%s'", Setup.SVDRPHostName, serverIpAddress.Connection(), *serverName);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -394,7 +399,6 @@ bool cSVDRPClient::Send(const char *Command)
 | 
				
			|||||||
bool cSVDRPClient::Process(cStringList *Response)
 | 
					bool cSVDRPClient::Process(cStringList *Response)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (file.IsOpen()) {
 | 
					  if (file.IsOpen()) {
 | 
				
			||||||
     char input[BUFSIZ];
 | 
					 | 
				
			||||||
     int numChars = 0;
 | 
					     int numChars = 0;
 | 
				
			||||||
#define SVDRPResonseTimeout 5000 // ms
 | 
					#define SVDRPResonseTimeout 5000 // ms
 | 
				
			||||||
     cTimeMs Timeout(SVDRPResonseTimeout);
 | 
					     cTimeMs Timeout(SVDRPResonseTimeout);
 | 
				
			||||||
@@ -438,10 +442,17 @@ bool cSVDRPClient::Process(cStringList *Response)
 | 
				
			|||||||
                  numChars = 0;
 | 
					                  numChars = 0;
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
               else {
 | 
					               else {
 | 
				
			||||||
                  if (numChars >= int(sizeof(input))) {
 | 
					                  if (numChars >= length - 1) {
 | 
				
			||||||
                     esyslog("SVDRP %s < %s ERROR: out of memory", Setup.SVDRPHostName, serverIpAddress.Connection());
 | 
					                     int NewLength = length + BUFSIZ;
 | 
				
			||||||
                     Close();
 | 
					                     if (char *NewBuffer = (char *)realloc(input, NewLength)) {
 | 
				
			||||||
                     break;
 | 
					                        length = NewLength;
 | 
				
			||||||
 | 
					                        input = NewBuffer;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                     else {
 | 
				
			||||||
 | 
					                        esyslog("SVDRP %s < %s ERROR: out of memory", Setup.SVDRPHostName, serverIpAddress.Connection());
 | 
				
			||||||
 | 
					                        Close();
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                     }
 | 
					                     }
 | 
				
			||||||
                  input[numChars++] = c;
 | 
					                  input[numChars++] = c;
 | 
				
			||||||
                  input[numChars] = 0;
 | 
					                  input[numChars] = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user