Fix base filename too long

I've recently ran across #23

I think the solution proposed in commit  9745cd54aea911776b810f782211062c9c255782
is just a local workaround. The correct solution would be to do not check the filename string size
prematurely, since filename could be a full absolute path.
We should just check the net basename string size against sz
(right before doing the final strcpy into base)

I've also implemented the regression test to this proposed solution.