* [meta-oe][sumo][PATCH] systemd: fix codesonar warnings
@ 2020-08-07 14:31 Amitanand N Chikorde
2020-08-07 14:48 ` [OE-core] " Quentin Schulz
2020-08-07 15:02 ` ✗ patchtest: failure for systemd: Fix codesonar warnings (rev4) Patchwork
0 siblings, 2 replies; 3+ messages in thread
From: Amitanand N Chikorde @ 2020-08-07 14:31 UTC (permalink / raw)
To: openembedded-core, raj.khem
Cc: nisha.parrakat, anuj.chougule, amitanand.chikorde
Fixed below systemd codesonar warnings.
1. isprint() and isspace() is invoked here with an argument of signed
type char, but only has defined behavior for int arguments that are
either representable as unsigned char or equal to the value
of macro EOF(-1).
As per codesonar report, in a number of libc implementations, isprint()
and isspace() functions implemented using lookup tables (arrays):
passing in a negative value can result in a read underrun.
To avoid this unexpected behaviour, typecasted char type argument to
unsigned char type.
2. "seqnum" defined, not initialized & used in device-private.c
Intialized "seqnum" at definition.
Signed-off-by: Amitanand <Amitanand.Chikorde@kpit.com>
---
.../systemd/systemd_codesonar_warnings_fix.patch | 105 +++++++++++++++++++++
meta/recipes-core/systemd/systemd_245.6.bb | 1 +
2 files changed, 106 insertions(+)
create mode 100644 meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
diff --git a/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch b/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
new file mode 100644
index 0000000..a62f968
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
@@ -0,0 +1,105 @@
+systemd: fix codesonar warnings
+
+Fixed below systemd codesonar warnings.
+1. isprint() and isspace() is invoked here with an argument of signed
+type char, but only has defined behavior for int arguments that are
+either representable as unsigned char or equal to the value
+of macro EOF(-1).
+
+As per codesonar report, in a number of libc implementations, isprint()
+and isspace() functions implemented using lookup tables (arrays):
+passing in a negative value can result in a read underrun.
+
+To avoid this unexpected behaviour, typecasted char type argument to
+unsigned char type.
+
+2. "seqnum" defined, not initialized & used in device-private.c
+Intialized "seqnum" at definition.
+
+Upstream-Status: Pending
+Signed-off-by: Amitanand N. Chikorde <Amitanand.Chikorde@kpit.com>
+
+--- origcode/src/libsystemd/sd-device/device-private.c 2020-07-09 18:05:13.744127907 +0530
++++ modifcode/src/libsystemd/sd-device/device-private.c 2020-07-09 18:01:56.494621945 +0530
+@@ -560,7 +560,7 @@
+ char **key;
+ const char *major = NULL, *minor = NULL;
+ DeviceAction action = _DEVICE_ACTION_INVALID;
+- uint64_t seqnum;
++ uint64_t seqnum = 0;
+ int r;
+
+ assert(ret);
+--- origcode/src/libudev/libudev-util.c 2020-07-09 18:05:13.656049515 +0530
++++ modifcode/src/libudev/libudev-util.c 2020-07-09 18:02:32.563386414 +0530
+@@ -171,7 +171,7 @@
+
+ /* strip trailing whitespace */
+ len = strnlen(str, len);
+- while (len && isspace(str[len-1]))
++ while (len && isspace((unsigned char) str[len-1]))
+ len--;
+
+ /* strip leading whitespace */
+@@ -182,8 +182,8 @@
+ j = 0;
+ while (i < len) {
+ /* substitute multiple whitespace with a single '_' */
+- if (isspace(str[i])) {
+- while (isspace(str[i]))
++ if (isspace((unsigned char) str[i])) {
++ while (isspace((unsigned char) str[i]))
+ i++;
+ to[j++] = '_';
+ }
+--- origcode/src/udev/udevadm-hwdb.c 2020-07-09 18:05:13.612010318 +0530
++++ modifcode/src/udev/udevadm-hwdb.c 2020-07-09 18:03:26.243530163 +0530
+@@ -487,7 +487,7 @@
+
+ /* strip trailing whitespace */
+ len = strlen(line);
+- while (len > 0 && isspace(line[len-1]))
++ while (len > 0 && isspace((unsigned char) line[len-1]))
+ len--;
+ line[len] = '\0';
+
+--- origcode/src/udev/udevadm-info.c 2020-07-09 18:05:13.616013882 +0530
++++ modifcode/src/udev/udevadm-info.c 2020-07-09 18:03:41.621625782 +0530
+@@ -73,7 +73,7 @@
+
+ /* skip nonprintable attributes */
+ len = strlen(value);
+- while (len > 0 && isprint(value[len-1]))
++ while (len > 0 && isprint((unsigned char) value[len-1]))
+ len--;
+ if (len > 0)
+ continue;
+--- origcode/src/udev/udev-rules.c 2020-07-09 18:05:13.624021008 +0530
++++ modifcode/src/udev/udev-rules.c 2020-07-09 18:03:03.227995790 +0530
+@@ -726,7 +726,7 @@
+ return -1;
+
+ /* skip whitespace */
+- while (isspace(linepos[0]) || linepos[0] == ',')
++ while (isspace((unsigned char) linepos[0]) || linepos[0] == ',')
+ linepos++;
+
+ /* get the key */
+@@ -738,7 +738,7 @@
+ linepos++;
+ if (linepos[0] == '\0')
+ return -1;
+- if (isspace(linepos[0]))
++ if (isspace((unsigned char) linepos[0]))
+ break;
+ if (linepos[0] == '=')
+ break;
+@@ -751,7 +751,7 @@
+ temp = linepos;
+
+ /* skip whitespace after key */
+- while (isspace(linepos[0]))
++ while (isspace((unsigned char) linepos[0]))
+ linepos++;
+ if (linepos[0] == '\0')
+ return -1;
diff --git a/meta/recipes-core/systemd/systemd_245.6.bb b/meta/recipes-core/systemd/systemd_245.6.bb
index cdafb98..63c58e1 100644
--- a/meta/recipes-core/systemd/systemd_245.6.bb
+++ b/meta/recipes-core/systemd/systemd_245.6.bb
@@ -21,6 +21,7 @@ SRC_URI += "file://touchscreen.rules \
file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
file://0003-implment-systemd-sysv-install-for-OE.patch \
file://CVE-2020-13776.patch \
+ file://systemd_codesonar_warnings_fix.patch \
"
# patches needed by musl
--
2.7.4
This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [OE-core] [meta-oe][sumo][PATCH] systemd: fix codesonar warnings
2020-08-07 14:31 [meta-oe][sumo][PATCH] systemd: fix codesonar warnings Amitanand N Chikorde
@ 2020-08-07 14:48 ` Quentin Schulz
2020-08-07 15:02 ` ✗ patchtest: failure for systemd: Fix codesonar warnings (rev4) Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Quentin Schulz @ 2020-08-07 14:48 UTC (permalink / raw)
To: Amitanand N Chikorde
Cc: openembedded-core, raj.khem, nisha.parrakat, anuj.chougule
Hi Amitanand,
On Fri, Aug 07, 2020 at 08:01:47PM +0530, Amitanand N Chikorde wrote:
> Fixed below systemd codesonar warnings.
> 1. isprint() and isspace() is invoked here with an argument of signed
> type char, but only has defined behavior for int arguments that are
> either representable as unsigned char or equal to the value
> of macro EOF(-1).
>
> As per codesonar report, in a number of libc implementations, isprint()
> and isspace() functions implemented using lookup tables (arrays):
> passing in a negative value can result in a read underrun.
>
> To avoid this unexpected behaviour, typecasted char type argument to
> unsigned char type.
>
> 2. "seqnum" defined, not initialized & used in device-private.c
> Intialized "seqnum" at definition.
>
> Signed-off-by: Amitanand <Amitanand.Chikorde@kpit.com>
> ---
> .../systemd/systemd_codesonar_warnings_fix.patch | 105 +++++++++++++++++++++
> meta/recipes-core/systemd/systemd_245.6.bb | 1 +
> 2 files changed, 106 insertions(+)
> create mode 100644 meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
>
> diff --git a/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch b/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
> new file mode 100644
> index 0000000..a62f968
> --- /dev/null
> +++ b/meta/recipes-core/systemd/systemd/systemd_codesonar_warnings_fix.patch
> @@ -0,0 +1,105 @@
> +systemd: fix codesonar warnings
> +
> +Fixed below systemd codesonar warnings.
> +1. isprint() and isspace() is invoked here with an argument of signed
> +type char, but only has defined behavior for int arguments that are
> +either representable as unsigned char or equal to the value
> +of macro EOF(-1).
> +
> +As per codesonar report, in a number of libc implementations, isprint()
> +and isspace() functions implemented using lookup tables (arrays):
> +passing in a negative value can result in a read underrun.
> +
> +To avoid this unexpected behaviour, typecasted char type argument to
> +unsigned char type.
> +
> +2. "seqnum" defined, not initialized & used in device-private.c
> +Intialized "seqnum" at definition.
> +
> +Upstream-Status: Pending
Part of 1. is a backport:
https://github.com/systemd/systemd/commit/e7e954243a17cceb5278aac6249ee0dcc119b1eb
so please backport the patch entirely.
And make separate patch(es) for the rest if they aren't already
merged upstream.
As for the content of the patch (if it's a patch candidate), I'll let
maintainers decide/review.
> +Signed-off-by: Amitanand N. Chikorde <Amitanand.Chikorde@kpit.com>
> +
> +--- origcode/src/libsystemd/sd-device/device-private.c 2020-07-09 18:05:13.744127907 +0530
> ++++ modifcode/src/libsystemd/sd-device/device-private.c 2020-07-09 18:01:56.494621945 +0530
Does this patch even apply correctly? c.f. origcode/modifcode
Cheers,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread
* ✗ patchtest: failure for systemd: Fix codesonar warnings (rev4)
2020-08-07 14:31 [meta-oe][sumo][PATCH] systemd: fix codesonar warnings Amitanand N Chikorde
2020-08-07 14:48 ` [OE-core] " Quentin Schulz
@ 2020-08-07 15:02 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2020-08-07 15:02 UTC (permalink / raw)
To: Amitanand N Chikorde; +Cc: openembedded-core
== Series Details ==
Series: systemd: Fix codesonar warnings (rev4)
Revision: 4
URL : https://patchwork.openembedded.org/series/25093/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:
* Patch [meta-oe,sumo] systemd: fix codesonar warnings
Issue Series sent to the wrong mailing list [test_target_mailing_list]
Suggested fix Check the project's README (meta-oe,sumo) and send the patch to the indicated list
* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch sumo (currently at 84f19e78d9)
If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).
---
Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-07 15:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 14:31 [meta-oe][sumo][PATCH] systemd: fix codesonar warnings Amitanand N Chikorde
2020-08-07 14:48 ` [OE-core] " Quentin Schulz
2020-08-07 15:02 ` ✗ patchtest: failure for systemd: Fix codesonar warnings (rev4) Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox