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

 
 

bug #52220: 'find -D' segfaults

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

Add a New Comment Rich Markup
   

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:
https://git.sv.gnu.org/cgit/findutils.git/commit/?id=ef1581ea51

Bernhard Voelker <berny>
Group administrator
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>
Group administrator
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,
Berny

Bernhard Voelker <berny>
Group administrator
Thu 12 Oct 2017 08:30:12 PM UTC, original submission:  

Hello,

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.
segfault

Thank you for your time.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    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.13-4448.
    Corresponding source code