Import upstream patch to fix chfn (#1096187)
https://github.com/shadow-maint/shadow/pull/1212
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
From: Chris Hofstaedtler <zeha@debian.org>
|
||||
Date: Mon, 17 Feb 2025 12:26:07 +0100
|
||||
Subject: Partially revert "lib/, src/: Use strsep(3) instead of its pattern"
|
||||
|
||||
This reverts src/chfn.c from commit 16cb664865541162c504a6f5ef5ca4b38b5e0c9a.
|
||||
---
|
||||
src/chfn.c | 17 +++++++++++------
|
||||
1 file changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 4c96fba..f06cb44 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -216,27 +216,32 @@ static void new_fields (void)
|
||||
*/
|
||||
static char *copy_field (char *in, char *out, char *extra)
|
||||
{
|
||||
- while (NULL != in) {
|
||||
- char *f;
|
||||
+ char *cp = NULL;
|
||||
|
||||
- f = strsep(&in, ",");
|
||||
+ while (NULL != in) {
|
||||
+ cp = strchr (in, ',');
|
||||
+ if (NULL != cp) {
|
||||
+ *cp++ = '\0';
|
||||
+ }
|
||||
|
||||
- if (strchr(f, '=') == NULL)
|
||||
+ if (strchr (in, '=') == NULL) {
|
||||
break;
|
||||
+ }
|
||||
|
||||
if (NULL != extra) {
|
||||
if (!streq(extra, "")) {
|
||||
strcat (extra, ",");
|
||||
}
|
||||
|
||||
- strcat(extra, f);
|
||||
+ strcat (extra, in);
|
||||
}
|
||||
+ in = cp;
|
||||
}
|
||||
if ((NULL != in) && (NULL != out)) {
|
||||
strcpy (out, in);
|
||||
}
|
||||
|
||||
- return in;
|
||||
+ return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
5
debian/patches/series
vendored
5
debian/patches/series
vendored
@@ -10,5 +10,8 @@ upstream/a015e919834c90b99947829c6c823f7fe93a8097-E_BAD_NAME.patch
|
||||
upstream/man-useradd.8.xml-Document-new-exit-code-19-E_BAD_NAME.patch
|
||||
upstream/Revert-lib-src-Use-local-time-for-human-readable-dates.patch
|
||||
Revert-lib-strtoday.c-strtoday-Fix-calculation.patch
|
||||
Partially-revert-lib-src-Use-strsep-3-instead-of-its-patt.patch
|
||||
Warn-when-badname-and-variants-are-given.patch
|
||||
upstream/src-chfn.c-Partially-revert-lib-src-Use-strsep-3-instead-.patch
|
||||
upstream/src-chfn.c-Use-stpsep-instead-of-its-pattern.patch
|
||||
upstream/src-chfn.c-Add-local-variable-to-refer-to-the-separated-f.patch
|
||||
upstream/src-chfn.c-copy_field-Rename-local-variable.patch
|
||||
|
||||
37
debian/patches/upstream/src-chfn.c-Add-local-variable-to-refer-to-the-separated-f.patch
vendored
Normal file
37
debian/patches/upstream/src-chfn.c-Add-local-variable-to-refer-to-the-separated-f.patch
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:44:55 +0100
|
||||
Subject: src/chfn.c: Add local variable to refer to the separated field
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 1799d6b..3fc94dc 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -220,18 +220,20 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
char *cp = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
+ const char *f;
|
||||
+
|
||||
+ f = in;
|
||||
cp = stpsep(in, ",");
|
||||
|
||||
- if (strchr (in, '=') == NULL) {
|
||||
+ if (strchr(f, '=') == NULL)
|
||||
break;
|
||||
- }
|
||||
|
||||
if (NULL != extra) {
|
||||
if (!streq(extra, "")) {
|
||||
strcat (extra, ",");
|
||||
}
|
||||
|
||||
- strcat (extra, in);
|
||||
+ strcat(extra, f);
|
||||
}
|
||||
in = cp;
|
||||
}
|
||||
67
debian/patches/upstream/src-chfn.c-Partially-revert-lib-src-Use-strsep-3-instead-.patch
vendored
Normal file
67
debian/patches/upstream/src-chfn.c-Partially-revert-lib-src-Use-strsep-3-instead-.patch
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:23:37 +0100
|
||||
Subject: src/chfn.c: Partially revert "lib/,
|
||||
src/: Use strsep(3) instead of its pattern"
|
||||
|
||||
This partially reverts commit 16cb664865541162c504a6f5ef5ca4b38b5e0c9a.
|
||||
|
||||
I'll try to reintroduce this change more carefully.
|
||||
For now, let's revert to a known-good state.
|
||||
|
||||
The problem was due to accidentally ignoring the effects of the 'break'
|
||||
on the 'cp' variable.
|
||||
|
||||
Fixes: 16cb66486554 (2024-07-01; "lib/, src/: Use strsep(3) instead of its pattern")
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1210>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1213>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1212>
|
||||
Reported-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 17 +++++++++++------
|
||||
1 file changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 4c96fba..f06cb44 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -216,27 +216,32 @@ static void new_fields (void)
|
||||
*/
|
||||
static char *copy_field (char *in, char *out, char *extra)
|
||||
{
|
||||
- while (NULL != in) {
|
||||
- char *f;
|
||||
+ char *cp = NULL;
|
||||
|
||||
- f = strsep(&in, ",");
|
||||
+ while (NULL != in) {
|
||||
+ cp = strchr (in, ',');
|
||||
+ if (NULL != cp) {
|
||||
+ *cp++ = '\0';
|
||||
+ }
|
||||
|
||||
- if (strchr(f, '=') == NULL)
|
||||
+ if (strchr (in, '=') == NULL) {
|
||||
break;
|
||||
+ }
|
||||
|
||||
if (NULL != extra) {
|
||||
if (!streq(extra, "")) {
|
||||
strcat (extra, ",");
|
||||
}
|
||||
|
||||
- strcat(extra, f);
|
||||
+ strcat (extra, in);
|
||||
}
|
||||
+ in = cp;
|
||||
}
|
||||
if ((NULL != in) && (NULL != out)) {
|
||||
strcpy (out, in);
|
||||
}
|
||||
|
||||
- return in;
|
||||
+ return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
33
debian/patches/upstream/src-chfn.c-Use-stpsep-instead-of-its-pattern.patch
vendored
Normal file
33
debian/patches/upstream/src-chfn.c-Use-stpsep-instead-of-its-pattern.patch
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:40:02 +0100
|
||||
Subject: src/chfn.c: Use stpsep() instead of its pattern
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index f06cb44..1799d6b 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "string/strcmp/streq.h"
|
||||
#include "string/strcpy/strtcpy.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
+#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -219,10 +220,7 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
char *cp = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
- cp = strchr (in, ',');
|
||||
- if (NULL != cp) {
|
||||
- *cp++ = '\0';
|
||||
- }
|
||||
+ cp = stpsep(in, ",");
|
||||
|
||||
if (strchr (in, '=') == NULL) {
|
||||
break;
|
||||
47
debian/patches/upstream/src-chfn.c-copy_field-Rename-local-variable.patch
vendored
Normal file
47
debian/patches/upstream/src-chfn.c-copy_field-Rename-local-variable.patch
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 15:33:46 +0100
|
||||
Subject: src/chfn.c: copy_field(): Rename local variable
|
||||
|
||||
This makes it more obvious what that pointer is.
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 3fc94dc..d62bb8a 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -217,13 +217,13 @@ static void new_fields (void)
|
||||
*/
|
||||
static char *copy_field (char *in, char *out, char *extra)
|
||||
{
|
||||
- char *cp = NULL;
|
||||
+ char *next = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
const char *f;
|
||||
|
||||
f = in;
|
||||
- cp = stpsep(in, ",");
|
||||
+ next = stpsep(in, ",");
|
||||
|
||||
if (strchr(f, '=') == NULL)
|
||||
break;
|
||||
@@ -235,13 +235,13 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
|
||||
strcat(extra, f);
|
||||
}
|
||||
- in = cp;
|
||||
+ in = next;
|
||||
}
|
||||
if ((NULL != in) && (NULL != out)) {
|
||||
strcpy (out, in);
|
||||
}
|
||||
|
||||
- return cp;
|
||||
+ return next;
|
||||
}
|
||||
|
||||
/*
|
||||
Reference in New Issue
Block a user