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)".
This commit is contained in:
Jiri Popelka 2011-05-04 16:56:54 +02:00 committed by Tim Waugh
parent f70e892baf
commit dd69faff4d

View File

@ -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;