That looks like it could write the terminating NUL beyond the bounds of targetbuf in the pathological case where rc is PATH_MAX...
_________________________
Toby Speight
030103016 (80GB Mk2a, blue)
030102806 (0GB Mk2a, blue)