Opened 11 years ago

Closed 6 years ago

#6187 closed Bugs (invalid)

boost::filesystem::exists will thought a string is which include zero, is a file, exactly is the file is not exist.

Reported by: js1011 <jiangshui584520@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.48.0 Severity: Problem
Keywords: filesystem Cc:

Description

A string like this; std::string path = "/usr/lib/"; path.append(2, 0x0); path.append(3, 'x');

boost::filesystem::exists function will thought this 'path' is a directory.

thanks regards.

Change History (3)

comment:1 by viboes, 11 years ago

Component: Nonefilesystem
Owner: set to Beman Dawes

comment:2 by alexis.legoadec@…, 6 years ago

Hello,

I have opened a pull-request with the fix here: https://github.com/boostorg/filesystem/pull/28

comment:3 by Beman Dawes, 6 years ago

Resolution: invalid
Status: newclosed

It isn't the job of class path to decide on validity of strings passed to it.

Asian character encodings may have embedded '\0' characters. Shift-JIS is an example, IIRC. If you know the encoding of a string that is going to be used as a path, you could check it for validity before passing it to a path.

Thanks,

--Beman

Note: See TracTickets for help on using tickets.