| 1 |
/* { dg-additional-options "-fconserve-stack" } */ |
| 2 |
|
| 3 |
/* Check to make sure that if |
| 4 |
rfc4106_set_hash_subkey gets split, |
| 5 |
the error function does not gets split away |
| 6 |
from the if statement conditionalizing it. */ |
| 7 |
|
| 8 |
struct crypto_aes_ctx { |
| 9 |
char key_dec[128]; |
| 10 |
}; |
| 11 |
|
| 12 |
int rfc4106_set_hash_subkey_hash_subkey; |
| 13 |
|
| 14 |
void __write_overflow(void)__attribute__((__error__(""))); |
| 15 |
void __write_overflow1(void); |
| 16 |
void aes_encrypt(void*); |
| 17 |
|
| 18 |
void fortify_panic(const char*) __attribute__((__noreturn__)) ; |
| 19 |
|
| 20 |
char *rfc4106_set_hash_subkey(struct crypto_aes_ctx *ctx) { |
| 21 |
void *a = &ctx->key_dec[0]; |
| 22 |
unsigned p_size = __builtin_object_size(a, 0); |
| 23 |
#ifdef __OPTIMIZE__ |
| 24 |
if (p_size < 16) { |
| 25 |
__write_overflow1(); |
| 26 |
fortify_panic(__func__); |
| 27 |
} |
| 28 |
if (p_size < 32) { |
| 29 |
__write_overflow(); |
| 30 |
fortify_panic(__func__); |
| 31 |
} |
| 32 |
#endif |
| 33 |
aes_encrypt(ctx); |
| 34 |
return ctx->key_dec; |
| 35 |
} |
| 36 |
|
| 37 |
char *(*gg)(struct crypto_aes_ctx *) = rfc4106_set_hash_subkey; |
| 38 |
|
| 39 |
void a(void) |
| 40 |
{ |
| 41 |
struct crypto_aes_ctx ctx; |
| 42 |
rfc4106_set_hash_subkey(&ctx); |
| 43 |
} |
| 44 |
void b(void) |
| 45 |
{ |
| 46 |
struct crypto_aes_ctx ctx; |
| 47 |
ctx.key_dec[0] = 0; |
| 48 |
rfc4106_set_hash_subkey(&ctx); |
| 49 |
} |
| 50 |
|