瀏覽代碼

fix segfault in ccm_memory() with LTC_CLEAN_STACK

we shouldn't clean user-supplied variables
Steffen Jaeckel 8 年之前
父節點
當前提交
e05097e413
共有 1 個文件被更改,包括 3 次插入1 次删除
  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) {