Browse Source

fix segfault in ccm_memory() with LTC_CLEAN_STACK

we shouldn't clean user-supplied variables
Steffen Jaeckel 8 years ago
parent
commit
e05097e413
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/encauth/ccm/ccm_memory.c

+ 3 - 1
src/encauth/ccm/ccm_memory.c

@@ -333,6 +333,9 @@ int ccm_memory(int cipher,
 
    if (skey != uskey) {
       cipher_descriptor[cipher].done(skey);
+#ifdef LTC_CLEAN_STACK
+      zeromem(skey,   sizeof(*skey));
+#endif
    }
 
    if (direction == CCM_ENCRYPT) {
@@ -380,7 +383,6 @@ int ccm_memory(int cipher,
    fastMask = 0;
 #endif
    mask = 0;
-   zeromem(skey,   sizeof(*skey));
    zeromem(PAD,    sizeof(PAD));
    zeromem(CTRPAD, sizeof(CTRPAD));
    if (pt_work != NULL) {