further checks against corrupt hlr

This commit is contained in:
gardners 2011-10-02 21:18:16 +10:30
parent d90b921188
commit 5778e9d016
2 changed files with 5 additions and 2 deletions

5
dna.c
View File

@ -74,7 +74,7 @@ struct mphlr_variable vars[]={
{0x00,NULL,NULL}
};
int sock;
int sock=-1;
#ifndef HAVE_BZERO
/* OpenWRT doesn't have bzero */
@ -275,6 +275,7 @@ char *exec_args[128];
int exec_argc=0;
void signal_handler( int signal ) {
/* oops - caught a bad signal -- exec() ourselves fresh */
if (sock>-1) close(sock);
execv(exec_args[0],exec_args);
/* Quit if the exec() fails */
exit(-3);
@ -304,7 +305,7 @@ int main(int argc,char **argv)
signal( SIGFPE, signal_handler );
signal( SIGILL, signal_handler );
signal( SIGBUS, signal_handler );
signal( SIGABRT, signal_handler );
#endif
srandomdev();

View File

@ -241,6 +241,8 @@ int hlrGetRecordLength(unsigned char *hlr,int hofs)
if (debug>2) fprintf(stderr,"HLR record @ 0x%x is %d bytes long.\n",hofs,record_length);
if (record_length<0) return 0;
return record_length;
}