socsvn commit: r289830 - soc2013/def/crashdump-head/sbin/cryptcore

def at FreeBSD.org def at FreeBSD.org
Mon Aug 17 17:44:07 UTC 2015


Author: def
Date: Mon Aug 17 17:44:06 2015
New Revision: 289830
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=289830

Log:
  Use a variable instead of a structure name to calculate size.

Modified:
  soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c

Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c
==============================================================================
--- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c	Mon Aug 17 16:51:37 2015	(r289829)
+++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c	Mon Aug 17 17:44:06 2015	(r289830)
@@ -111,20 +111,20 @@
 		pjdlog_exitx(1, "Unable to allocate an RSA structure.");
 	EVP_CIPHER_CTX_init(&ctx);
 
-	kdk = calloc(1, sizeof(struct kerneldumpkey));
+	kdk = calloc(1, sizeof(*kdk));
 	if (kdk == NULL)
 		pjdlog_exit(1, "Unable to allocate kernel dump key");
 
 	fd = open(keyfile, O_RDONLY);
 	if (fd == -1)
 		pjdlog_exit(1, "Unable to open %s", keyfile);
-	size = read(fd, kdk, sizeof(struct kerneldumpkey));
-	if (size == (ssize_t)sizeof(struct kerneldumpkey)) {
+	size = read(fd, kdk, sizeof(*kdk));
+	if (size == (ssize_t)sizeof(*kdk)) {
 		kdk = realloc(kdk, kdk->kdk_size);
 		if (kdk == NULL)
 			pjdlog_exit(1, "Unable to reallocate kernel dump key");
 		size += read(fd, &kdk->kdk_encryptedkey,
-		    kdk->kdk_size - sizeof(struct kerneldumpkey));
+		    kdk->kdk_size - sizeof(*kdk));
 	}
 	err = errno;
 	close(fd);


More information about the svn-soc-all mailing list