Commit b812eb0076235743872b5c9d18714d2324cc668d
Committed by
Herbert Xu
1 parent
dad3df2044
Exists in
master
and in
4 other branches
crypto: testmgr - Validate output length in (de)compression tests
When self-testing (de)compression algorithms, make sure the actual size of the (de)compressed output data matches the expected output size. Otherwise, in case the actual output size would be smaller than the expected output size, the subsequent buffer compare test would still succeed, and no error would be reported. Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 16 additions and 0 deletions Side-by-side Diff
crypto/testmgr.c
... | ... | @@ -843,6 +843,14 @@ |
843 | 843 | goto out; |
844 | 844 | } |
845 | 845 | |
846 | + if (dlen != ctemplate[i].outlen) { | |
847 | + printk(KERN_ERR "alg: comp: Compression test %d " | |
848 | + "failed for %s: output len = %d\n", i + 1, algo, | |
849 | + dlen); | |
850 | + ret = -EINVAL; | |
851 | + goto out; | |
852 | + } | |
853 | + | |
846 | 854 | if (memcmp(result, ctemplate[i].output, dlen)) { |
847 | 855 | printk(KERN_ERR "alg: comp: Compression test %d " |
848 | 856 | "failed for %s\n", i + 1, algo); |
... | ... | @@ -864,6 +872,14 @@ |
864 | 872 | printk(KERN_ERR "alg: comp: decompression failed " |
865 | 873 | "on test %d for %s: ret=%d\n", i + 1, algo, |
866 | 874 | -ret); |
875 | + goto out; | |
876 | + } | |
877 | + | |
878 | + if (dlen != dtemplate[i].outlen) { | |
879 | + printk(KERN_ERR "alg: comp: Decompression test %d " | |
880 | + "failed for %s: output len = %d\n", i + 1, algo, | |
881 | + dlen); | |
882 | + ret = -EINVAL; | |
867 | 883 | goto out; |
868 | 884 | } |
869 | 885 |