Skip to content

Commit 2b7fe56

Browse files
nickdesaulniersraphielscape
authored andcommitted
KEYS: trusted: fix -Wvarags warning
Fixes the warning reported by Clang: security/keys/trusted.c:146:17: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs] va_start(argp, h3); ^ security/keys/trusted.c:126:37: note: parameter of type 'unsigned char' is declared here unsigned char *h2, unsigned char h3, ...) ^ Specifically, it seems that both the C90 (4.8.1.1) and C11 (7.16.1.4) standards explicitly call this out as undefined behavior: The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter parmN is declared with ... or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined. Link: ClangBuiltLinux/linux#41 Link: https://www.eskimo.com/~scs/cclass/int/sx11c.html Suggested-by: David Laight <[email protected]> Suggested-by: Denis Kenzior <[email protected]> Suggested-by: James Bottomley <[email protected]> Suggested-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Albert I <[email protected]> Signed-off-by: Raphiel Rollerscaperers <[email protected]>
1 parent c8931f8 commit 2b7fe56

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/keys/trusted.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum {
3838

3939
int TSS_authhmac(unsigned char *digest, const unsigned char *key,
4040
unsigned int keylen, unsigned char *h1,
41-
unsigned char *h2, unsigned char h3, ...);
41+
unsigned char *h2, unsigned int h3, ...);
4242
int TSS_checkhmac1(unsigned char *buffer,
4343
const uint32_t command,
4444
const unsigned char *ononce,

security/keys/trusted.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key,
123123
*/
124124
int TSS_authhmac(unsigned char *digest, const unsigned char *key,
125125
unsigned int keylen, unsigned char *h1,
126-
unsigned char *h2, unsigned char h3, ...)
126+
unsigned char *h2, unsigned int h3, ...)
127127
{
128128
unsigned char paramdigest[SHA1_DIGEST_SIZE];
129129
struct sdesc *sdesc;
@@ -139,7 +139,7 @@ int TSS_authhmac(unsigned char *digest, const unsigned char *key,
139139
return PTR_ERR(sdesc);
140140
}
141141

142-
c = h3;
142+
c = !!h3;
143143
ret = crypto_shash_init(&sdesc->shash);
144144
if (ret < 0)
145145
goto out;

0 commit comments

Comments
 (0)