Fix crash on TERM signal (unintialized memory)

This commit is contained in:
Ron Pedde 2006-07-19 05:55:05 +00:00
parent 1063187b27
commit dd5b5acdac
2 changed files with 11 additions and 8 deletions

View File

@ -171,17 +171,19 @@ void rend_callback(void *info) {
} }
src=dst=msg.txt; src=dst=msg.txt;
while(src && (*src)) { while(src && (*src) && (src - msg.txt < MAX_TEXT_LEN)) {
len = (*src); len = (*src);
if((src + len + 1) - msg.txt < MAX_TEXT_LEN) {
memmove(dst,src+1,len); memmove(dst,src+1,len);
dst += len; dst += len;
src += len + 1;
if(*src) { if(*src) {
*dst++ = '\001'; *dst++ = '\001';
} else { } else {
*dst='\0'; *dst='\0';
} }
} }
src += len + 1;
}
switch(msg.cmd) { switch(msg.cmd) {
case REND_MSG_TYPE_REGISTER: case REND_MSG_TYPE_REGISTER:

View File

@ -152,6 +152,7 @@ int rend_running(void) {
int rend_stop(void) { int rend_stop(void) {
REND_MESSAGE msg; REND_MESSAGE msg;
memset((void*)&msg,0x0,sizeof(msg));
msg.cmd=REND_MSG_TYPE_STOP; msg.cmd=REND_MSG_TYPE_STOP;
return rend_send_message(&msg); return rend_send_message(&msg);
} }