crypto: testmgr: change `guard` to unsigned char
Subsystems (2)
PATCH 1/1 crypto: testmgr: change `guard` to unsigned char
When char is signed, storing the values 0xba (186) and 0xad (173) in the guard array produces signed overflow. Change the type of guard to unsigned char to remove undefined behavior.
--- crypto/testmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/testmgr.c +1 -1
@@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,char *state;struct ahash_request *req;int statesize, ret = -EINVAL ; -const char guard[] = {0x00 ,0xba ,0xad ,0x00 }; +const unsigned char guard[] = {0x00 ,0xba ,0xad ,0x00 }; req = *preq; statesize = crypto_ahash_statesize(
Signature · 1 line
2.15.1
Quoted 3 lines · Joey Pabalinas
When char is signed, storing the values
0xba(186) and0xad(173) in theguardarray produces signed overflow. Change the type ofguardto unsigned char to remove undefined behavior.
[]
crypto/testmgr.c
Quoted 1 line
crypto/testmgr.c +0
-0
[]
crypto/testmgr.c static int ahash_partial_update(struct ahash_request **preq, · line 188
Quoted 6 lines
crypto/testmgr.c +1
-1@@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,char *state;struct ahash_request *req;int statesize, ret = -EINVAL ; -const char guard[] = {0x00 ,0xba ,0xad ,0x00 }; +const unsigned char guard[] = {0x00 ,0xba ,0xad ,0x00 };
Might as well add static too
Quoted 3 lines · Joe Perches
Might as well add static too
That's a good idea; I'll make a v2.
Signature · 1 line
Joey Pabalinas
PATCH v2 1/1 crypto: testmgr: change `guard` to unsigned char
In reply to Joe PerchesWhen char is signed, storing the values 0xba (186) and 0xad (173) in the guard array produces signed overflow. Change the type of guard to static unsigned char to correct undefined behavior and reduce function stack usage.
--- crypto/testmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/testmgr.c +1 -1
@@ -185,7 +185,7 @@ static int ahash_partial_update(struct ahash_request **preq,char *state;struct ahash_request *req;int statesize, ret = -EINVAL ; -const char guard[] = {0x00 ,0xba ,0xad ,0x00 }; +static const unsigned char guard[] = {0x00 ,0xba ,0xad ,0x00 }; req = *preq; statesize = crypto_ahash_statesize(
Signature · 1 line
2.15.1
Herbert Xu
maintainerQuoted 6 lines · Joey Pabalinas
When char is signed, storing the values
0xba(186) and0xad(173) in theguardarray produces signed overflow. Change the type ofguardto static unsigned char to correct undefined behavior and reduce function stack usage.Signed-off-by Joey Pabalinas <[email protected]>
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 2 lines · Herbert Xu
Patch applied. Thanks.
No problem, cheers.
Signature · 1 line
Joey Pabalinas