Bug 18704 - GLOB_ERR not handled correctly by glob()
Summary: GLOB_ERR not handled correctly by glob()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 4.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-05-21 06:30 UTC by douzzer
Modified: 2024-06-14 04:59 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (1.45 KB, patch)
2000-05-21 06:30 UTC, douzzer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description douzzer 2000-05-21 06:30:01 UTC
glob() (and internal funcs) never checks GLOB_ERR unless an error
handler pointer is passed.  Even with a handler, GLOB_ERR is only
partially implemented, and conditions which should activate the
semantic do not.  Finally, conditions which should not activate
the semantic do, rendering GLOB_ERR far less useful than it should
be (a TODO identifying this problem was in the source tree, and
I implemented the fix).

Fix: The following context diff was pasted from emacs - tabs are intact.
How-To-Repeat: Do that math :-P
glob("/secretdir/*",GLOB_ERR,0,&globbuf) where /secretdir is not
accessible - should result in negative return value, but does not.
Comment 1 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 03:40:12 UTC
State Changed
From-To: open->feedback


Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE?
Comment 2 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 04:12:50 UTC
On Sat, Jul 21, 2001 at 10:47:04PM -0400, Daniel Pouzzner wrote:
> >Does this problem still occur in newer versions of FreeBSD,
> >such as 4.3-RELEASE?
> 
> I submitted that bug report so long I don't even remember what I was
> working on that had me using the glob routines.  I do remember
> submitting the bug report at least.
> 
> Can you send me a URL where I can read my bug report for a refresher?

Hmm, the URL should have been at the bottom of the message Gnats
sent you.  Anyway, here it is:

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18704

Best regards,
Mike Barcroft
Comment 3 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 04:44:26 UTC
State Changed
From-To: feedback->suspended


This is still a problem.  Awaiting committer.
Comment 4 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 04:53:42 UTC
Adding to Audit-Trail.

On Sat, Jul 21, 2001 at 11:17:42PM -0400, Daniel Pouzzner wrote:
> I just checked the 4.3 code (Mar 28 modtime on glob.c) and no repair
> has been implemented (notably, my suggested repair has not been
> merged).
> 
>   Synopsis: GLOB_ERR not handled correctly by glob()
>   
>   State-Changed-From-To: open->feedback
>   State-Changed-By: mike
>   State-Changed-When: Sat Jul 21 19:40:12 PDT 2001
>   State-Changed-Why: 
>   
>   Does this problem still occur in newer versions of FreeBSD,
>   such as 4.3-RELEASE?
>   
>   http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18704
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:52:48 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"
Comment 6 Warner Losh freebsd_committer freebsd_triage 2024-01-15 18:02:31 UTC
This patch no longer applies and is incomplete.
It looks like it could be applied carefully by hand, but would then need some additional work to handle more cases.
Comment 7 Warner Losh freebsd_committer freebsd_triage 2024-06-14 04:59:02 UTC
So this bug has been fixed by other ways. The following works:

#include <err.h>
#include <glob.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
        glob_t globbuf;

        if (glob("/secretdir/*",GLOB_ERR,0,&globbuf) == 0)
                errx(1, "FAILED");
        printf("SUCCESS");
        exit(0);
}