The example never executes code inside of the while loop, as read()
returns bigger number than 0. Thus the end result is wrong.
CLA: trivial
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11143)
if (!EVP_MAC_init(ctx))
goto err;
- while ( (read_l = read(STDIN_FILENO, buf, sizeof(buf))) < 0) {
+ while ( (read_l = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
if (!EVP_MAC_update(ctx, buf, read_l))
goto err;
}
$ MY_MAC=cmac MY_KEY=secret0123456789 MY_MAC_CIPHER=aes-128-cbc \
LD_LIBRARY_PATH=. ./foo < foo.c
- Result: ECCAAFF041B22A2299EB90A1B53B6D45
+ Result: C5C06683CD9DDEF904D754505C560A4E
(in this example, that program was stored in F<foo.c> and compiled to
F<./foo>)