diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-09-05 09:34:25 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-09-05 10:05:24 +0300 |
commit | e0ae31fcce3bd57b24751ff3c82cba820e493c3a (patch) | |
tree | a8676136e5690eef1f4702eb6dea2507a624dd8f /src/misc.c | |
parent | 50ec983666f0ca9d50c84aa1afad0d7bd5810779 (diff) | |
download | libgcrypt-e0ae31fcce3bd57b24751ff3c82cba820e493c3a.tar.gz |
Change _gcry_burn_stack take burn depth as unsigned integer
* src/misc.c (_gcry_burn_stack): Change to handle 'unsigned int' bytes.
--
Unsigned integer is better here for code generation because we can now avoid
possible branching caused by (bytes <= 0) check.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -288,10 +288,11 @@ _gcry_log_printhex (const char *text, const void *buffer, size_t length) void -_gcry_burn_stack (int bytes) +_gcry_burn_stack (unsigned int bytes) { #ifdef HAVE_VLA - int buflen = (((bytes <= 0) ? 1 : bytes) + 63) & ~63; + /* (bytes == 0 ? 1 : bytes) == (!bytes + bytes) */ + unsigned int buflen = ((!bytes + bytes) + 63) & ~63; volatile char buf[buflen]; wipememory (buf, sizeof buf); @@ -300,9 +301,8 @@ _gcry_burn_stack (int bytes) wipememory (buf, sizeof buf); - bytes -= sizeof buf; - if (bytes > 0) - _gcry_burn_stack (bytes); + if (bytes > sizeof buf) + _gcry_burn_stack (bytes - sizeof buf); #endif } |