IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 21 years ago

Closed 21 years ago

Last modified 20 years ago

#524 closed defect (fixed)

psTraceV segfault and related problems

Reported by: eugene Owned by: David.Robbins@…
Priority: high Milestone:
Component: sys Version: 0.7.0
Severity: critical Keywords:
Cc:

Description


Attachments (2)

psTrace.c (24.2 KB ) - added by eugene 21 years ago.
psTrace.c fixes
vsprintf-sample.c (635 bytes ) - added by eugene 21 years ago.
vsprintf discovery example

Download all attachments as: .zip

Change History (7)

comment:1 by eugene, 21 years ago

psTraceV has some serious bugs in the code related to printing the message. It
calls fmt = va_arg(ap, char *) even though the function received va_list, not
the ellipsis (...) argument. It also is printing the format line nLevel times
rather than just a space. Basically, it is all buggered up.

In a related vein, I am concerned about the use of FILE * implementations of the
trace printing commands when the APIs are being passed file descriptors. Mixing
and matching between these can be done, but it can be dangerous. It is also not
needed in this case. sprintf and write can be used to replace fprintf. I have
implemented a version of psTrace.c using fd's and fixing the bug in psTraceV,
which i am attaching.

Another problem in this code is the behavior when the trace destination is given
as 0. The SDRS says the code should not emit any trace messages, and points out
the similarity of destination = 0,1,2 equivalent to STDIN, STDOUT, STDERR. The
document says that the symbol PS_TRACE_NONE should be defined for 0, equivalent
to the position of STDIN. The code instead sets the destination actually to
STDIN. This seems dangerous, and is not what is requested. This is also fixed
in the sample.

Finally, the sample code does not dynamically allocate the line: the psLib
implementation should do so. I am attaching a second block of code illustrating
the use of vsprintf and a 0 byte output line to discover how much memory to
allocate.

by eugene, 21 years ago

Attachment: psTrace.c added

psTrace.c fixes

comment:2 by Paul Price, 21 years ago

I clarified the behaviour of psTraceSetDestination recently, so the 0,1,2 ==
stdin,stdout,stderr probably isn't in the last version of the SDRS.

by eugene, 21 years ago

Attachment: vsprintf-sample.c added

vsprintf discovery example

comment:3 by Paul Price, 21 years ago

Severity: normalcritical

comment:4 by robert.desonia@…, 21 years ago

Owner: changed from robert.desonia@… to David.Robbins@…

comment:5 by David.Robbins@…, 21 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.