From: Colin K. <col...@gm...> - 2010-07-08 12:46:47
|
Hi, I keep having intermittent problems with the assert in this code from sshguard-1.5rc3/src/sshguard_logsuck.c 351 /* read until error, newline reached, or buffer exhausted */ 352 i = 0; 353 do { 354 ret = read(fd, & buf[i++], 1); 355 } while (ret == 1 && buf[i-1] != '\n' && i < buflen-2); 356 assert(ret != 0); 357 buf[i] = '\0'; I keep getting the error message; Assertion `ret != 0' failed. I added some code to print the various values that are used: if(ret == 0) { sshguard_log(LOG_NOTICE, "ret = %d, i = %d, buflen = %d, buf[i-1] = '%c', buf = %s\n", ret, i, (int)buflen, buf[i-1], buf); } and from that received this output; ret = 0, i = 62, buflen = 999, buf[i-1] = 'n', buf = ul 07 16:45:26 thor.hagenhosting.com proftpd[18688] thor.hagenhosting.com (61.55.146.28[61.55.146.28]): FTP session closed. Why is ret == 0 bad? Doesn't that just me EOF? I'm reading from /var/log/ftp.log which is written to by syslog (it is just easier that way) so isn't this just saying that syslog hadn't finished writing the entire line to the log file while I was reading it and thus hit the EOF before the EOL? This is really annoying because when it happens sshguard falls over and so leaves the box open to annoyances again. Thanks, Colin. |