[openssh-commits] [openssh] 02/10: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Nov 16 11:31:51 AEDT 2015


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit a7994b3f5a5a5a33b52b0a6065d08e888f0a99fb
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Wed Nov 11 04:56:39 2015 +0000

    upstream commit
    
    improve PEEK/POKE macros: better casts, don't multiply
     evaluate arguments; ok deraadt@
    
    Upstream-ID: 9a1889e19647615ededbbabab89064843ba92d3e
---
 sshbuf.h | 61 ++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/sshbuf.h b/sshbuf.h
index eb0d92e..8e330e4 100644
--- a/sshbuf.h
+++ b/sshbuf.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: sshbuf.h,v 1.4 2015/01/14 15:02:39 djm Exp $	*/
+/*	$OpenBSD: sshbuf.h,v 1.5 2015/11/11 04:56:39 djm Exp $	*/
 /*
  * Copyright (c) 2011 Damien Miller
  *
@@ -241,45 +241,48 @@ int	sshbuf_b64tod(struct sshbuf *buf, const char *b64);
 
 /* Macros for decoding/encoding integers */
 #define PEEK_U64(p) \
-	(((u_int64_t)(((u_char *)(p))[0]) << 56) | \
-	 ((u_int64_t)(((u_char *)(p))[1]) << 48) | \
-	 ((u_int64_t)(((u_char *)(p))[2]) << 40) | \
-	 ((u_int64_t)(((u_char *)(p))[3]) << 32) | \
-	 ((u_int64_t)(((u_char *)(p))[4]) << 24) | \
-	 ((u_int64_t)(((u_char *)(p))[5]) << 16) | \
-	 ((u_int64_t)(((u_char *)(p))[6]) << 8) | \
-	  (u_int64_t)(((u_char *)(p))[7]))
+	(((u_int64_t)(((const u_char *)(p))[0]) << 56) | \
+	 ((u_int64_t)(((const u_char *)(p))[1]) << 48) | \
+	 ((u_int64_t)(((const u_char *)(p))[2]) << 40) | \
+	 ((u_int64_t)(((const u_char *)(p))[3]) << 32) | \
+	 ((u_int64_t)(((const u_char *)(p))[4]) << 24) | \
+	 ((u_int64_t)(((const u_char *)(p))[5]) << 16) | \
+	 ((u_int64_t)(((const u_char *)(p))[6]) << 8) | \
+	  (u_int64_t)(((const u_char *)(p))[7]))
 #define PEEK_U32(p) \
-	(((u_int32_t)(((u_char *)(p))[0]) << 24) | \
-	 ((u_int32_t)(((u_char *)(p))[1]) << 16) | \
-	 ((u_int32_t)(((u_char *)(p))[2]) << 8) | \
-	  (u_int32_t)(((u_char *)(p))[3]))
+	(((u_int32_t)(((const u_char *)(p))[0]) << 24) | \
+	 ((u_int32_t)(((const u_char *)(p))[1]) << 16) | \
+	 ((u_int32_t)(((const u_char *)(p))[2]) << 8) | \
+	  (u_int32_t)(((const u_char *)(p))[3]))
 #define PEEK_U16(p) \
-	(((u_int16_t)(((u_char *)(p))[0]) << 8) | \
-	  (u_int16_t)(((u_char *)(p))[1]))
+	(((u_int16_t)(((const u_char *)(p))[0]) << 8) | \
+	  (u_int16_t)(((const u_char *)(p))[1]))
 
 #define POKE_U64(p, v) \
 	do { \
-		((u_char *)(p))[0] = (((u_int64_t)(v)) >> 56) & 0xff; \
-		((u_char *)(p))[1] = (((u_int64_t)(v)) >> 48) & 0xff; \
-		((u_char *)(p))[2] = (((u_int64_t)(v)) >> 40) & 0xff; \
-		((u_char *)(p))[3] = (((u_int64_t)(v)) >> 32) & 0xff; \
-		((u_char *)(p))[4] = (((u_int64_t)(v)) >> 24) & 0xff; \
-		((u_char *)(p))[5] = (((u_int64_t)(v)) >> 16) & 0xff; \
-		((u_char *)(p))[6] = (((u_int64_t)(v)) >> 8) & 0xff; \
-		((u_char *)(p))[7] = ((u_int64_t)(v)) & 0xff; \
+		const u_int64_t __v = (v); \
+		((u_char *)(p))[0] = (__v >> 56) & 0xff; \
+		((u_char *)(p))[1] = (__v >> 48) & 0xff; \
+		((u_char *)(p))[2] = (__v >> 40) & 0xff; \
+		((u_char *)(p))[3] = (__v >> 32) & 0xff; \
+		((u_char *)(p))[4] = (__v >> 24) & 0xff; \
+		((u_char *)(p))[5] = (__v >> 16) & 0xff; \
+		((u_char *)(p))[6] = (__v >> 8) & 0xff; \
+		((u_char *)(p))[7] = __v & 0xff; \
 	} while (0)
 #define POKE_U32(p, v) \
 	do { \
-		((u_char *)(p))[0] = (((u_int64_t)(v)) >> 24) & 0xff; \
-		((u_char *)(p))[1] = (((u_int64_t)(v)) >> 16) & 0xff; \
-		((u_char *)(p))[2] = (((u_int64_t)(v)) >> 8) & 0xff; \
-		((u_char *)(p))[3] = ((u_int64_t)(v)) & 0xff; \
+		const u_int32_t __v = (v); \
+		((u_char *)(p))[0] = (__v >> 24) & 0xff; \
+		((u_char *)(p))[1] = (__v >> 16) & 0xff; \
+		((u_char *)(p))[2] = (__v >> 8) & 0xff; \
+		((u_char *)(p))[3] = __v & 0xff; \
 	} while (0)
 #define POKE_U16(p, v) \
 	do { \
-		((u_char *)(p))[0] = (((u_int64_t)(v)) >> 8) & 0xff; \
-		((u_char *)(p))[1] = ((u_int64_t)(v)) & 0xff; \
+		const u_int16_t __v = (v); \
+		((u_char *)(p))[0] = (__v >> 8) & 0xff; \
+		((u_char *)(p))[1] = __v & 0xff; \
 	} while (0)
 
 /* Internal definitions follow. Exposed for regress tests */

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list