[vdr] vdr 1.3.25 thread problems
Klaus Schmidinger
Klaus.Schmidinger at cadsoft.de
Wed Jun 1 21:30:24 CEST 2005
Rainer Zocholl wrote:
>
> Again:
> The most beloved problem: Reentrancy...
>
> This C-Function in tools.c looks suspicious:
>
> cString TimeToString(time_t t)
> {
> char buffer[32];
> if (ctime_r(&t, buffer)) {
> buffer[strlen(buffer) - 1] = 0; // strip trailing newline
> return buffer;
> }
> return "???";
> }
>
>
> It's usually no good idea to deference a variable on the stack
> OUTSIDE the function it self..the next call to an other
> functiom may overwrite the values!
> It might work very often, but it is not really much better than a "static"!
>
> Is there really no tool like "bounds checker for linux"
> that will warn at those obvious booby traps?
>
>
>
> Having a deja vue:
> I thought all that was "overworked" with the
> "thread-save" patches 3 month ago?
>
> Or didn't these patches made the way into VDR?
>
>
>
> The fastest fix may be:
> Make it like in ctime_r an define a buffer pint as parameter.
> The slowest: use the ugly time wasting asprintf and never forget
> to free the memory...
cString creates a copy of buffer upon return.
Klaus
More information about the vdr
mailing list