afsio: switch BreakUpPath to strdup
authorBenjamin Kaduk <kaduk@mit.edu>
Wed, 20 May 2015 14:57:53 +0000 (10:57 -0400)
committerDaria Brashear <shadow@your-file-system.com>
Tue, 26 May 2015 17:58:35 +0000 (13:58 -0400)
commitb8648dbefb3968329d20cad8976ce15947428678
treeb5a979de5ad3350c456948c52ccbf442cabaef53
parent9076cbd58dd48801ad212f803f586fdc53d7b886
afsio: switch BreakUpPath to strdup

The current version of BreakUpPath is slightly broken, since
commit 4e68282e26b0c4569d25d076d54274f0da47a691 -- it has two
output parameters but takes only one length parameter for the
size of the output buffers passed in.  The callers ended up using
the shorter of the buffer lengths in question, so there is not
a risk of a buffer overrun, but long paths would not be properly
handled.

There is not really any need to pass in a length at all, since
what is going on is conceptually strdup, and there is no real
need to use strlcpy at all.  Make the change from strlcpy to
str(n)dup, and adjust callers to free the outputs as appropriate.

While here, convert writeFile() to use goto and a cleanup handler
to avoid leaks.

Change-Id: Ib742cb73a6d70aa863c8d30423416887b977677b
Reviewed-on: http://gerrit.openafs.org/11874
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
src/venus/afsio.c