All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release
@ 2020-08-20 13:30 Petr Vorel
  2020-08-20 13:45 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2020-08-20 13:30 UTC (permalink / raw)
  To: ltp

ID is normally without double quotes, e.g.: ID=debian

But at least SLES and openSUSE contain double quotes, e.g.:
ID="opensuse-tumbleweed"

thus optionally strip the double quotes after scanning them.

Fixes: e2e60a39b ("lib/tst_kvercmp: Add support /etc/os-release")

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_kvercmp.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/tst_kvercmp.c b/lib/tst_kvercmp.c
index 185a5c39c..5d56e30b9 100644
--- a/lib/tst_kvercmp.c
+++ b/lib/tst_kvercmp.c
@@ -131,6 +131,7 @@ int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
 const char *tst_kvcmp_distname(const char *kver)
 {
 	static char distname[64];
+	char *ret = distname;
 	char *p = distname;
 
 	if (strstr(kver, ".el5uek"))
@@ -148,12 +149,21 @@ const char *tst_kvcmp_distname(const char *kver)
 	if (access(OSRELEASE_PATH, F_OK) != -1) {
 		SAFE_FILE_LINES_SCANF(NULL, OSRELEASE_PATH, "ID=%s", distname);
 
+		if (p[0] == '"') {
+			ret = distname + 1;
+			p = ret;
+		}
+
 		while (*p) {
+			if (*p == '"') {
+				*p = 0;
+				break;
+			}
 			*p = toupper((unsigned char)*p);
 			p++;
 		}
 
-		return distname;
+		return ret;
 	}
 
 	return NULL;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release
  2020-08-20 13:30 [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release Petr Vorel
@ 2020-08-20 13:45 ` Cyril Hrubis
  2020-08-20 14:57   ` Po-Hsu Lin
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2020-08-20 13:45 UTC (permalink / raw)
  To: ltp

Hi!
Looks good to me.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release
  2020-08-20 13:45 ` Cyril Hrubis
@ 2020-08-20 14:57   ` Po-Hsu Lin
  2020-08-20 20:33     ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Po-Hsu Lin @ 2020-08-20 14:57 UTC (permalink / raw)
  To: ltp

LGTM,
Tested with crafted ID, it can correctly parse the ID with or without
the double quote.

Another thing to note is that I found the loop in tst_kvercmp2 could
iterate outside the size of "vers" and causing
tst_test.c:1298: BROK: Test killed by SIGSEGV!

Reviewed-by: Po-Hsu Lin <po-hsu.lin@canonical.com>

On Thu, Aug 20, 2020 at 9:45 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> Looks good to me.
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>
> --
> Cyril Hrubis
> chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release
  2020-08-20 14:57   ` Po-Hsu Lin
@ 2020-08-20 20:33     ` Petr Vorel
  2020-08-21  3:10       ` Po-Hsu Lin
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2020-08-20 20:33 UTC (permalink / raw)
  To: ltp

Hi Po-Hsu,

> LGTM,
> Tested with crafted ID, it can correctly parse the ID with or without
> the double quote.

> Another thing to note is that I found the loop in tst_kvercmp2 could
> iterate outside the size of "vers" and causing
> tst_test.c:1298: BROK: Test killed by SIGSEGV!
Will you post the patch for this?

> Reviewed-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
I'm sorry, I've merged it before, but forget to notify.
Is the bug mentioned above related to my commit?

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release
  2020-08-20 20:33     ` Petr Vorel
@ 2020-08-21  3:10       ` Po-Hsu Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Po-Hsu Lin @ 2020-08-21  3:10 UTC (permalink / raw)
  To: ltp

On Fri, Aug 21, 2020 at 4:33 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Po-Hsu,
>
> > LGTM,
> > Tested with crafted ID, it can correctly parse the ID with or without
> > the double quote.
>
> > Another thing to note is that I found the loop in tst_kvercmp2 could
> > iterate outside the size of "vers" and causing
> > tst_test.c:1298: BROK: Test killed by SIGSEGV!
> Will you post the patch for this?
>
> > Reviewed-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> I'm sorry, I've merged it before, but forget to notify.
> Is the bug mentioned above related to my commit?
Hello Petr,
Don't worry it's not related to this commit :)
I will have a look at that bug.

Cheers
>
> Kind regards,
> Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-21  3:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-20 13:30 [LTP] [PATCH v3 1/1] tst_kvcmp: Strip double quotes when parsing /etc/os-release Petr Vorel
2020-08-20 13:45 ` Cyril Hrubis
2020-08-20 14:57   ` Po-Hsu Lin
2020-08-20 20:33     ` Petr Vorel
2020-08-21  3:10       ` Po-Hsu Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.