Project

General

Profile

Actions

Bug #992

closed

telldir/seekdir broken [PATCH]

Added by gstanley over 16 years ago. Updated about 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

FreeBSD has a bug in telldir that returns incorrect results, causing memory
leaks and other odd behavior. This bug was fixed in NetBSD, and I've created a
patch based on NetBSD's changes. This will also add a pointer to dd_internal
in dirent.h, which will probably require a version bump because the size of
that struct will change. I didn't bother bumping version here because it seems
it didn't effect anything (ls, du, etc), but its better to be safe than sorry.

The code to generate the issue is here:

http://leaf.dragonflybsd.org/~gary/patches/libc/seekdir-twice.c

Fixed telldir:

first found: a
pos returned by telldir: 135286864
second found: b
third found: c
should be second: b
pos given to seekdir: 135286864
pos returned by telldir: 135286864
should be second: b
should be second: b

Broken telldir:

first found: a
pos returned by telldir: 1
second found: b
third found: c
should be second: b
pos given to seekdir: 1
pos returned by telldir: 2
should be second: c
should be second: c

The patch is located here:
http://leaf.dragonflybsd.org/~gary/patches/libc/libc-telldir-memleaks.patch

Some notes:
telldir's behavior now follows opengroup's behavior, that it isn't const,
which it seems is more of a standards issue than anything.

http://www.opengroup.org/onlinepubs/009695399/functions/telldir.html

tgen@ has looked over the patch and says its good, only concern was the
unconst change to telldir, which I explained to him above :)

Actions

Also available in: Atom PDF