bugfindutils - Bugs: bug #52220, 'find -D' segfaults


bug #52220: 'find -D' segfaults

Submitted by:  None
Submitted on:  Thu 12 Oct 2017 08:30:12 PM UTC  
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Fixed
Privacy:  Public Assigned to:  Bernhard Voelker <berny>
Originator Name:  Felix Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.6.0
Fixed Release:  4.7.0

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 22 Oct 2017 06:53:57 PM UTC, comment #5: 

Thanks for the review - pushed (with the duplicate "the" in the
commit message removed) at:

Bernhard Voelker <berny>
Project AdministratorIn charge of this item.
Sat 21 Oct 2017 05:09:23 PM UTC, comment #4: 

Works for me, thanks!

$ ./find/find -D
./find/find: Missing argument after the -D option.
Try './find/find --help' for more information.

Tavian Barnes <tavianator>
Wed 18 Oct 2017 10:16:19 PM UTC, comment #3: 

Thanks, this seems to be a problem with certain strtok_r
implementations.  Mine here seems to handle NULL in the
first call.

Patch attached - please check.

(file #42192)

Bernhard Voelker <berny>
Project AdministratorIn charge of this item.
Sun 15 Oct 2017 09:31:49 PM UTC, comment #2: 

Reproduces here:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff775c2d2 in strtok_r () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff775c2d2 in strtok_r () from /usr/lib/libc.so.6
#1  0x0000555555561359 in process_debug_options (arg=0x0) at util.c:851
#2  process_leading_options (argc=<optimized out>, argv=<optimized out>) at util.c:973
#3  0x000055555555afba in main (argc=2, argv=0x7fffffffdcf8) at ftsfind.c:693

The code does

      else if (0 == strcmp ("-D", argv[i]))
          process_debug_options (argv[i+1]);
          ++i;                        /* skip the argument too. */

but argv[i+1] is NULL.  The first thing process_debug_options() does is

  p = strtok_r (arg, delimiters, &token_context);

NULL arg is invalid as the first call to strtok_r.

Tavian Barnes <tavianator>
Thu 12 Oct 2017 11:26:09 PM UTC, comment #1: 

I can't reproduce here:

 $ find/find -D
  find/find: Empty argument to the -D option.

  $ find/find --version
  find (GNU findutils) 4.6.0

and with the latest source from Git:

  $ find/find -D
  find/find: Empty argument to the -D option.
  Try 'find/find --help' for more information.

Would you please provide more information, like information about
your environment, a stack trace, maybe strace output, etc.?

Thanks & have a nice day,

Bernhard Voelker <berny>
Project AdministratorIn charge of this item.
Thu 12 Oct 2017 08:30:12 PM UTC, original submission:  


1. the version of findutils you are using
version 4.6.0

3. the exact command line that you used
find -D

4. what you expected to happen
I expected to get "find: '-D' must take an argument" or the help version of -D.

5. precisely what did happen.

Thank you for your time.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #42192:  0001-find-avoid-segfault-with-D-without-argument.patch added by berny (4KiB - text/x-patch - [PATCH] find: avoid segfault with -D without argument)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jay (Updated the item)
  • -email is unavailable- added by tavianator (Posted a comment)
  • -email is unavailable- added by berny (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-08-29 jay Open/ClosedOpen => Closed
    2019-08-29 berny Fixed Release4.6.0 => 4.7.0
    2017-10-22 berny StatusReady For Test => Fixed
    2017-10-18 berny Attached File- => Added 0001-find-avoid-segfault-with-D-without-argument.patch, #42192
        StatusNeed Info => Ready For Test
    2017-10-12 berny StatusNone => Need Info
        Assigned toNone => berny

    Back to the top

    Powered by Savane 3.5