package/tpm2-totp: fix error due to variable used uninitialized
PATCH 1/1 package/tpm2-totp: fix error due to variable used uninitialized
From: Carlos Santos <[email protected]>
Some inline declarations of strtok_r (specifically in Sourcery CodeBench Lite 2016.11-19) contain code where an '__s' local variable can be used uninitialized.
When GCC expands that declaration in tpm2-totp, __s becomes an alias to a variable which fact is not initialized, but this is not relevant since the execution path leading to the uninitialized use is never followed.
Anyway, apply a patch already submitted upstream to fix the compilation error.
Upstream bug report:
https://github.com/tpm2-software/tpm2-totp/issues/32
Fixes:
http://autobuild.buildroot.net/results/5693a35e4d6bc76a1f46fe0e217abc49f7188aad/
--- ...ion-failure-due-to-variable-may-be-u.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/tpm2-totp/0002-src-fix-compilation-failure-due-to-variable-may-be-u.patch
package/tpm2-totp/0002-src-fix-compilation-failure-due-to-variable-may-be-u.patch new file +42 -0
@@ -0,0 +1,42 @@ +From 194f41635367452a7a3c9a75ebbada531bf4c58d Mon Sep 17 00:00:00 2001 +From: Carlos Santos <[email protected]> +Date: Sun, 26 May 2019 13:39:44 -0300 +Subject: [PATCH] src: fix compilation failure due to "variable may be used + uninitialized" + +Some inline declarations of strtok_r (specifically in Sourcery CodeBench +Lite 2016.11-19) contain code where an '__s' local variable can be used +uninitialized. + +When GCC expands that declaration in 'parse_pcrs', __s becomes an alias +to the local variable 'saveptr', which in fact is not initialized, but +this is not relevant, since the 'str' argument is knowingly not NULL +when passed to strtok_r because it comes from 'optarg' in parse_opts. + +Anyway, initialize saveptr to NULL to prevent the compilation error. + +Fixes: + http://autobuild.buildroot.net/results/5693a35e4d6bc76a1f46fe0e217abc49f7188aad/ + +Change-Id: I03ad3731774c56744f18154ec161c92ba002903d +Signed-off-by: Carlos Santos <[email protected]> +--- + src/tpm2-totp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/tpm2-totp.c b/src/tpm2-totp.c +index 3f60b4a..f28a4d6 100644 +--- a/src/tpm2-totp.c ++++ b/src/tpm2-totp.c +@@ -93,7 +93,7 @@ int + parse_pcrs(char *str, int *pcrs) + { + char *token; +- char *saveptr; ++ char *saveptr = NULL; + char *endptr; + long pcr; + +-- +2.20.1 +
Signature · 1 line
2.20.1
PATCH 1/1 package/tpm2-totp: fix error due to variable used uninitialized
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"unixmania" == unixmania <[email protected]> writes:
From: Carlos Santos <[email protected]>
Some inline declarations ofstrtok_r(specifically in Sourcery CodeBench Lite 2016.11-19) contain code where an '__s' local variable can be used uninitialized.When GCC expands that declaration in tpm2-totp,
__sbecomes an alias to a variable which fact is not initialized, but this is not relevant since the execution path leading to the uninitialized use is never followed.Anyway, apply a patch already submitted upstream to fix the compilation error.
Quoted 7 lines
Upstream bug report:
https://github.com/tpm2-software/tpm2-totp/issues/32Fixes:
http://autobuild.buildroot.net/results/5693a35e4d6bc76a1f46fe0e217abc49f7188aad/Signed-off-by Carlos Santos <[email protected]>
Great, I also just started looking at the issue - Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard