tst_kvcmp: Strip double quotes when parsing /etc/os-release
PATCH v3 1/1 tst_kvcmp: Strip double quotes when parsing /etc/os-release
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.
--- lib/tst_kvercmp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
lib/tst_kvercmp.c +11 -1
@@ -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 ;
Signature · 1 line
2.28.0
PATCH v3 1/1 tst_kvcmp: Strip double quotes when parsing /etc/os-release
Hi!
Looks good to me.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 1/1 tst_kvcmp: Strip double quotes when parsing /etc/os-release
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!
Quoted 9 lines · Cyril Hrubis
Hi!
Looks good to me.Reviewed-by Cyril Hrubis <[email protected]>--
Cyril Hrubis
[email protected]
PATCH v3 1/1 tst_kvcmp: Strip double quotes when parsing /etc/os-release
Hi Po-Hsu,
Quoted 7 lines
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_kvercmp2could iterate outside the size of "vers" and causing tst_test.c:1298: BROK: Test killed by SIGSEGV!
Will you post the patch for this?
Quoted 1 line
Reviewed-by Po-Hsu Lin <[email protected]>
I'm sorry, I've merged it before, but forget to notify. Is the bug mentioned above related to my commit?
Kind regards,
Petr
PATCH v3 1/1 tst_kvcmp: Strip double quotes when parsing /etc/os-release
Quoted 7 lines · Petr Vorel
Hi Po-Hsu,
Quoted 3 lines
LGTM,
Tested with crafted ID, it can correctly parse the ID with or without the double quote.
Quoted 8 lines
Quoted 3 lines
Another thing to note is that I found the loop in
tst_kvercmp2could iterate outside the size of "vers" and causing tst_test.c:1298: BROK: Test killed by SIGSEGV!Will you post the patch for this?
Quoted 1 line
Reviewed-by Po-Hsu Lin <[email protected]>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
Quoted 3 lines
Kind regards,
Petr