Skip to content

Commit

Permalink
Bug 1389052 - Fix aligned_alloc emulation on i686, r=franziskus
Browse files Browse the repository at this point in the history
--HG--
extra : amend_source : c44074f0a18614025b28d5d84b7f213560c79612
  • Loading branch information
ueno committed Aug 10, 2017
1 parent 85619dd commit 4b7c82e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/freebl/gcm.c
Expand Up @@ -574,7 +574,7 @@ GCM_CreateContext(void *context, freeblCipherFunc cipher,
const unsigned char *params)
{
GCMContext *gcm = NULL;
gcmHashContext *ghash = NULL;
gcmHashContext *ghash = NULL, *ghashmem = NULL;
unsigned char H[MAX_BLOCK_SIZE];
unsigned int tmp;
PRBool freeCtr = PR_FALSE;
Expand All @@ -596,13 +596,13 @@ GCM_CreateContext(void *context, freeblCipherFunc cipher,
return NULL;
}
/* aligned_alloc is C11 so we have to do it the old way. */
ghash = PORT_ZAlloc(sizeof(gcmHashContext) + 15);
if (ghash == NULL) {
ghashmem = PORT_ZAlloc(sizeof(gcmHashContext) + 15);
if (ghashmem == NULL) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
goto loser;
}
ghash->mem = ghash;
ghash = (gcmHashContext *)(((uintptr_t)ghash + 15) & ~(uintptr_t)0x0F);
ghash = (gcmHashContext *)(((uintptr_t)ghashmem + 15) & ~(uintptr_t)0x0F);
ghash->mem = ghashmem;

/* first plug in the ghash context */
gcm->ghash_context = ghash;
Expand Down
10 changes: 6 additions & 4 deletions lib/freebl/rijndael.c
Expand Up @@ -1018,13 +1018,15 @@ AESContext *
AES_AllocateContext(void)
{
/* aligned_alloc is C11 so we have to do it the old way. */
AESContext *ctx = PORT_ZAlloc(sizeof(AESContext) + 15);
if (ctx == NULL) {
AESContext *ctx, *ctxmem;
ctxmem = PORT_ZAlloc(sizeof(AESContext) + 15);
if (ctxmem == NULL) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
return NULL;
}
ctx->mem = ctx;
return (AESContext *)(((uintptr_t)ctx + 15) & ~(uintptr_t)0x0F);
ctx = (AESContext *)(((uintptr_t)ctxmem + 15) & ~(uintptr_t)0x0F);
ctx->mem = ctxmem;
return ctx;
}

/*
Expand Down

0 comments on commit 4b7c82e

Please sign in to comment.