From: <no...@so...> - 2010-07-26 11:21:57
|
Update of /cvsroot/ijbswa/current In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv20500 Modified Files: errlog.c Log Message: In log_error(), assert that ival and sval have reasonable values. There's no reason not to abort() if they don't. Index: errlog.c =================================================================== RCS file: /cvsroot/ijbswa/current/errlog.c,v retrieving revision 1.105 retrieving revision 1.106 diff -u -d -r1.105 -r1.106 --- errlog.c 26 Jul 2010 11:20:53 -0000 1.105 +++ errlog.c 26 Jul 2010 11:21:47 -0000 1.106 @@ -794,27 +794,10 @@ * Takes 2 parameters: int length, const char * string. */ ival = va_arg(ap, int); + assert(ival >= 0); sval = va_arg(ap, char *); - if (sval == NULL) - { - format_string = "[null]"; - } - else if (ival <= 0) - { - if (0 == ival) - { - /* That's ok (but stupid) */ - tempbuf[0] = '\0'; - } - else - { - /* - * That's not ok (and even more stupid) - */ - assert(ival >= 0); - format_string = "[counted string lenght < 0]"; - } - } + assert(sval != NULL); + while ((ival-- > 0) && (length < log_buffer_size - 6)) { if (isprint((int)*sval) && (*sval != '\\')) |