From dd69faff4d15d6753e3d83177cf5509966c0bf81 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: May 16 2011 14:10:11 +0000 Subject: Coverity: Check return value of getfilecon(). Error: CHECKED_RETURN: patch-2.6.1/src/pch.c:736: check_return: Calling function "getfilecon" without checking return value (as is done elsewhere 4 out of 5 times). patch-2.6.1/src/inp.c:158: example_checked: "getfilecon(inname, &incontext)" has its value checked in "getfilecon(inname, &incontext) == -1". patch-2.6.1/src/patch.c:434: example_checked: "getfilecon(outname, &outcontext)" has its value checked in "getfilecon(outname, &outcontext) != -1". patch-2.6.1/src/pch.c:292: example_checked: "getfilecon(inname, &incontext)" has its value checked in "getfilecon(inname, &incontext) == -1". patch-2.6.1/src/util.c:603: example_checked: "getfilecon(filename, filecontext)" has its value checked in "getfilecon(filename, filecontext) == -1". patch-2.6.1/src/pch.c:736: unchecked_value: No check of the return value of "getfilecon(inname, &incontext)". --- diff --git a/patch-selinux.patch b/patch-selinux.patch index 904539c..a7920b0 100644 --- a/patch-selinux.patch +++ b/patch-selinux.patch @@ -97,9 +97,9 @@ diff -up patch-2.6.1/src/patch.c.selinux patch-2.6.1/src/patch.c } } diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c ---- patch-2.6.1/src/pch.c.selinux 2011-02-08 11:29:34.591271499 +0000 -+++ patch-2.6.1/src/pch.c 2011-02-08 11:30:08.810621570 +0000 -@@ -307,7 +307,12 @@ there_is_another_patch (bool need_header +--- patch-2.6.1/src/pch.c.selinux 2011-05-04 16:17:59.000000000 +0200 ++++ patch-2.6.1/src/pch.c 2011-05-04 16:49:45.000000000 +0200 +@@ -289,7 +289,12 @@ there_is_another_patch (bool need_header inname[t - buf - 1] = 0; if (stat (inname, &instat) == 0) { @@ -113,7 +113,7 @@ diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c invc = -1; } else -@@ -681,7 +686,7 @@ intuit_diff_type (bool need_header) +@@ -663,7 +668,7 @@ intuit_diff_type (bool need_header) if (cs) { if (version_get (p_name[i], cs, false, readonly, @@ -122,11 +122,13 @@ diff -up patch-2.6.1/src/pch.c.selinux patch-2.6.1/src/pch.c stat_errno[i] = 0; else version_controlled[i] = 0; -@@ -746,6 +751,7 @@ intuit_diff_type (bool need_header) +@@ -728,6 +733,9 @@ intuit_diff_type (bool need_header) invc = version_controlled[i]; instat = st[i]; validate_target_name (inname); -+ getfilecon (inname, &incontext); ++ if (getfilecon (inname, &incontext) == -1) ++ if (errno == ENODATA || errno == ENOTSUP) ++ *incontext = NULL; } return retval;