libselinux: src/label_android_property: do not leak fd on error

We were opening the path, but if the fstat failed or it was not a
regular file we would return without closing the fd.  Fix my using the
common error exit path rather than just returning.

Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Eric Paris 2013-02-05 19:15:42 -05:00
parent 5c0d7113de
commit 1e8f102e8c

View File

@ -161,11 +161,10 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
return -1; return -1;
if (fstat(fileno(fp), &sb) < 0) if (fstat(fileno(fp), &sb) < 0)
return -1; goto finish;
if (!S_ISREG(sb.st_mode)) { errno = EINVAL;
errno = EINVAL; if (!S_ISREG(sb.st_mode))
return -1; goto finish;
}
/* /*
* Two passes of the specification file. First is to get the size. * Two passes of the specification file. First is to get the size.