From 56bcd356d880e8959474a969ffa438f44d8a7b19 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 12 Nov 2013 22:00:54 +0100 Subject: [PATCH] heimdal: Fix CID 240779 Allocation size mismatch (rebased on current Heimdal by abartlet) The error Coverity complains about is in the malloc. krb5_enctypes is an enum, so it is usually smaller than the size of a pointer. So we overallocate, but in the memcpy further down we copy from potentially invalid memory. Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Wed Nov 13 11:05:44 CET 2013 on sn-devel-104 --- lib/krb5/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/krb5/context.c b/lib/krb5/context.c index bd01d8ef5..e738916d0 100644 --- a/lib/krb5/context.c +++ b/lib/krb5/context.c @@ -495,10 +495,10 @@ copy_etypes (krb5_context context, ; i++; - *ret_enctypes = malloc(sizeof(ret_enctypes[0]) * i); + *ret_enctypes = malloc(sizeof(enctypes[0]) * i); if (*ret_enctypes == NULL) return krb5_enomem(context); - memcpy(*ret_enctypes, enctypes, sizeof(ret_enctypes[0]) * i); + memcpy(*ret_enctypes, enctypes, sizeof(enctypes[0]) * i); return 0; }