NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/52295: find -delete: "relative path not safe" with absolute paths ...



>Number:         52295
>Category:       bin
>Synopsis:       find -delete: "relative path not safe" with absolute paths ...
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 13 09:10:00 +0000 2017
>Originator:     Anthony Mallet
>Release:        NetBSD 7.0.1,  7.99.75 -current as well
>Organization:
>Environment:
NetBSD fluffy64-netbsd7 7.0.1 NetBSD 7.0.1 (FLUFFY) #0: Tue Jun  7 14:30:24 CEST 2016  root@fluffy64-netbsd6:/usr/obj/sys/arch/amd64/compile/FLUFFY amd64

>Description:
/usr/bin/find /<path> -delete raises an error when given an absolute path.

This happens in usr.bin/find/function.c:467
/* Potentially unsafe - do not accept relative paths whatsoever */      
if (strchr(entry->fts_accpath, '/') != NULL)                            
        errx(1, "-delete: %s: relative path potentially not safe",      
                entry->fts_accpath);

I understand that the intent is to filter out slashes from anything that `find` would append to the user input <path>, however this is getting in the way in this case :)

>How-To-Repeat:
$ which find
/usr/bin/find
$ mkdir /tmp/test
$ find /tmp/test -delete
find: -delete: /tmp/test: relative path potentially not safe
$

While this is fine:
$ cd /tmp/test
$ find . -delete
$

>Fix:



Home | Main Index | Thread Index | Old Index