Opened 12 years ago

Closed 12 years ago

#4640 closed Bugs (fixed)

Fixed-sized array constructor can have unintended consequences

Reported by: boost@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.44.0 Severity: Problem
Keywords: fixed size array constructor Cc:

Description

As initially reported here: http://article.gmane.org/gmane.comp.lib.boost.devel/208444

The fixed-size array constructor takes the whole array, not accounting for possible null-terminators in the array.

Here is a more obvious test case that shows the problem:

void
array_ctor_test()
{
    char buf[256];
    strcpy(buf, "mydir/mysubdir");
 
    bfs::path p1(buf);
    bfs::path p2(&buf[0]);
    assert(p1 == p2); // Passes, because char-compares up to null
 
    p1 /= "extra";
    p2 /= "extra";
    assert(p1 == p2); // fail
}

Change History (2)

comment:1 by Beman Dawes, 12 years ago

This was fixed by changeset 64986, August 24, 2010.

Thanks,

--Beman

comment:2 by Beman Dawes, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.