public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH 2/2] musl: fix strftime crash
Date: Thu, 15 Feb 2024 09:02:01 -0800	[thread overview]
Message-ID: <20240215170201.1044011-2-raj.khem@gmail.com> (raw)
In-Reply-To: <20240215170201.1044011-1-raj.khem@gmail.com>

Apply a patch proposed by Rich to fix the init crashes

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...akage-in-last-commit-uninitialized-p.patch | 41 +++++++++++++++++++
 meta/recipes-core/musl/musl_git.bb            |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/musl/musl/0001-strftime-fix-breakage-in-last-commit-uninitialized-p.patch

diff --git a/meta/recipes-core/musl/musl/0001-strftime-fix-breakage-in-last-commit-uninitialized-p.patch b/meta/recipes-core/musl/musl/0001-strftime-fix-breakage-in-last-commit-uninitialized-p.patch
new file mode 100644
index 00000000000..b6ef5423de6
--- /dev/null
+++ b/meta/recipes-core/musl/musl/0001-strftime-fix-breakage-in-last-commit-uninitialized-p.patch
@@ -0,0 +1,41 @@
+From 46562816d15ecd66fab7ee916a3684de29b9789a Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 12 Feb 2024 14:40:53 -0800
+Subject: [PATCH] strftime: fix breakage in last commit (uninitialized pointer
+ access)
+
+commit f47a5d400b8ffa26cfc5b345dbff52fec94ac7f3 overlooked that
+strtoul was responsible for setting p to a const-laundered copy of the
+format string pointer f, even in the case where there was no number to
+parse. by making the call conditional on isdigit, that copy was lost.
+
+the logic here is a mess and should be cleaned up, but for now, this
+seems to be the least invasive change that undoes the breakage.
+
+Upstream-Status: Submitted [Rich Felker (musl maintainer) is the proposer of this patch]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/time/strftime.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/src/time/strftime.c b/src/time/strftime.c
+index ef590903..c40246db 100644
+--- a/src/time/strftime.c
++++ b/src/time/strftime.c
+@@ -234,7 +234,12 @@ size_t __strftime_l(char *restrict s, size_t n, const char *restrict f, const st
+ 		pad = 0;
+ 		if (*f == '-' || *f == '_' || *f == '0') pad = *f++;
+ 		if ((plus = (*f == '+'))) f++;
+-		width = isdigit(*f) ? strtoul(f, &p, 10) : 0;
++		if (isdigit(*f)) {
++			width = strtoul(f, &p, 10);
++		} else {
++			width = 0;
++			p = (void *)f;
++		}
+ 		if (*p == 'C' || *p == 'F' || *p == 'G' || *p == 'Y') {
+ 			if (!width && p!=f) width = 1;
+ 		} else {
+-- 
+2.43.1
+
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index fb2b188e010..190e16a6e1d 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -13,6 +13,7 @@ PV = "${BASEVER}+git"
 SRC_URI = "git://git.musl-libc.org/musl;branch=master \
            file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
            file://0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch \
+           file://0001-strftime-fix-breakage-in-last-commit-uninitialized-p.patch \
           "
 
 S = "${WORKDIR}/git"
-- 
2.43.2



  reply	other threads:[~2024-02-15 17:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 17:02 [PATCH 1/2] musl: Update to latest tip of trunk Khem Raj
2024-02-15 17:02 ` Khem Raj [this message]
2024-03-23 20:47 ` [OE-core] " Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240215170201.1044011-2-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox