setcifsacl: fix some bugs in build_fetched_aces
authorJeff Layton <jlayton@samba.org>
Wed, 7 Nov 2012 15:19:19 +0000 (10:19 -0500)
committerJeff Layton <jlayton@samba.org>
Wed, 7 Nov 2012 15:19:19 +0000 (10:19 -0500)
commit486eae46e07f792e83fb9c83df61834b5d7e0077
tree67a64fb2a7eba55bc8725df39a6705c5b658e071
parent786725279edf0a3ab684e68743e56c1412d95c59
setcifsacl: fix some bugs in build_fetched_aces

Pavel Raiskup reported the following defects that he found with Coverity:

"If the variable 'facesptr' on line cifs-utils-4.8.1/setcifsacl.c|365|
has not enough memory to be allocated, program 'setcifsacl' will fail
with segfault on line 365 (dereferencing facesptr)."

"you may return freed pointer here. There is some kind of return code
('rc') which should be transferred to >NULL< when is rc nonzero (and
returned)"

There are also a couple of other bugs here:

malloc doesn't necessarily set errno to anything when an allocation
fails, so having the error handling rely on that is wrong.

Fix all of these bugs by reorganzing this function to fix up the error
handling.

Reported-by: Pavel Raiskup <praiskup@redhat.com>
Signed-off-by: Jeff Layton <jlayton@samba.org>
setcifsacl.c