Bug #992

telldir/seekdir broken [PATCH]

Added by gstanley over 6 years ago. Updated almost 5 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

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 :)

History

#1 Updated by dillon over 6 years ago

:New submission from Gary Stanley <>:
:
:FreeBSD has a bug in telldir that returns incorrect results, causing memory=20
:leaks and other odd behavior. This bug was fixed in NetBSD, and I've create=
:d a=20
:patch based on NetBSD's changes. This will also add a pointer to dd_interna=
:l=20
:in dirent.h, which will probably require a version bump because the size of=20
:that struct will change. I didn't bother bumping version here because it se=
:ems=20
:it didn't effect anything (ls, du, etc), but its better to be safe than sor=
:ry.
:
:The code to generate the issue is here:
:
:http://leaf.dragonflybsd.org/~gary/patches/libc/seekdir-twice.c

Ok, I see what's going on here. I'm going to play with it a bit,
I don't entirely like NetBSD's solution.

-Matt

#2 Updated by tuxillo almost 5 years ago

What happened to this? Was already solved or forgotten?

#3 Updated by dillon almost 5 years ago

:Antonio Huete Jimenez <> added the comment:
:
:What happened to this? Was already solved or forgotten?

I think this was solved a different way via commit
8276f8bcdceacb4a572533a0ffcbd87dd8e541c0.

-Matt
Matthew Dillon
<>

Also available in: Atom PDF