Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  30 Mar 2004, Konstantin Olchanski, , elog fixes elog-fixes.txt
    Reply  30 Mar 2004, Stefan Ritt, , elog fixes 
Message ID: 64     Entry time: 30 Mar 2004     Reply to this: 65
Author: Konstantin Olchanski 
Topic:  
Subject: elog fixes 
I am about to commit the mhttpd Elog fixes we have been using in TWIST since
about October. The infamous Elog "last N days" problem is fixed, sundry
memory overruns are caught and assert()ed.

For the curious, the "last N days" problem was caused by uninitialized data
in the elog handling code. A non-zero-terminated string was read from a file
and passed to atoi(). Here is a simplifed illustration:

char str[256]; // uninitialized, filled with whatever happens on the stack
read(file,str,6); // read 6 bytes, non-zero terminated
// str now looks like this: "123456UUUUUUUUU....", "U" is uninitialized memory
int len = atoi(str); // if the first "U" happens to be a number, we lose.

The obvious fix is to add "str[6]=0" before the atoi() call.

Attached is the CVS diff for the proposed changes. Please comment.

K.O.
Attachment 1: elog-fixes.txt  5 kB  Uploaded 24 Sep 2004  | Show | Show all
ELOG V3.1.4-2e1708b5