-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7dHbgACgkQrlYvE4MpobMtLwCgy9f/Ptxvo8ef7gUXpV0QMAGZ FWAAn1DkhHGBYpaxIDHYE/LURjrTOPfq =o6Oa -----END PGP SIGNATURE-----
>From 685155cbac7ce0ce35e92c3c3c0bc532df4ef84f Mon Sep 17 00:00:00 2001 From: Richard Haines <richard_c_haines@xxxxxxxxxxxxxx> Date: Sun, 27 Nov 2011 16:09:58 +0000 Subject: [PATCH 40/48] libselinux: get_default_type now sets EINVAL if no entry. get_default_type(3) now returns with errno set to EINVAL if the entry does not exist. Signed-off-by: Richard Haines <richard_c_haines@xxxxxxxxxxxxxx> Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- libselinux/src/get_default_type.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libselinux/src/get_default_type.c b/libselinux/src/get_default_type.c index 6fd1681..ca3d291 100644 --- a/libselinux/src/get_default_type.c +++ b/libselinux/src/get_default_type.c @@ -3,6 +3,7 @@ #include <string.h> #include <ctype.h> #include "get_default_type_internal.h" +#include <errno.h> static int find_default_type(FILE * fp, const char *role, char **type); @@ -32,8 +33,10 @@ static int find_default_type(FILE * fp, const char *role, char **type) len = strlen(role); while (!feof_unlocked(fp)) { - if (!fgets_unlocked(buf, sizeof buf, fp)) + if (!fgets_unlocked(buf, sizeof buf, fp)) { + errno = EINVAL; return -1; + } if (buf[strlen(buf) - 1]) buf[strlen(buf) - 1] = 0; @@ -53,8 +56,10 @@ static int find_default_type(FILE * fp, const char *role, char **type) } } - if (!found) + if (!found) { + errno = EINVAL; return -1; + } t = malloc(strlen(buf) - len); if (!t) -- 1.7.7.4