[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#36321: ix86 direction flag not preserved over strstr() call



Austin Donnelly <and1000@cam.ac.uk> writes:
>
> Package: libc6
> Version: 2.1.1
> 
> The definition of strstr(3) in ./sysdeps/i386/i486/bits/string.h
> includes a fragment of assembly:
 
[snip]
 
> Note that it clears the direction flag (cld), but never restores it to
> its previous value.  This could be a problem if someone sets the
> direction bit in EFLAGS.  This same problem is present in quite a few
> other functions in string.h

The calling conventions say the direction flag should be clear on
function entry and exit, so glibc is correct.  (See chapter 3 of the
iBCS2 book.)

If anything, actually, the cld would be unnecessary, but I guess glibc
doesn't want to rely on it.


Reply to: