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 #1

Updated by dillon over 16 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
Actions #2

Updated by tuxillo about 15 years ago

What happened to this? Was already solved or forgotten?

Actions #3

Updated by dillon about 15 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
&lt;&gt;
Actions

Also available in: Atom PDF