diff options
author | Colin Watson <cjwatson@debian.org> | 2016-02-29 12:15:15 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2016-03-08 11:51:22 +0000 |
commit | 46961f5704f8e86cea3e99253faad55aef4d8f35 (patch) | |
tree | 0dd97fa4fb649a62b4639fe2674380872b1f3e98 /sshbuf.h | |
parent | c753fe267efb1b027424fa8706cf0385fc3d14c1 (diff) | |
parent | 85e40e87a75fb80a0bf893ac05a417d6c353537d (diff) |
New upstream release (7.2).
Diffstat (limited to 'sshbuf.h')
-rw-r--r-- | sshbuf.h | 65 |
1 files changed, 34 insertions, 31 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshbuf.h,v 1.4 2015/01/14 15:02:39 djm Exp $ */ | 1 | /* $OpenBSD: sshbuf.h,v 1.6 2015/12/10 07:01:35 mmcc Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2011 Damien Miller | 3 | * Copyright (c) 2011 Damien Miller |
4 | * | 4 | * |
@@ -120,12 +120,12 @@ size_t sshbuf_len(const struct sshbuf *buf); | |||
120 | size_t sshbuf_avail(const struct sshbuf *buf); | 120 | size_t sshbuf_avail(const struct sshbuf *buf); |
121 | 121 | ||
122 | /* | 122 | /* |
123 | * Returns a read-only pointer to the start of the the data in buf | 123 | * Returns a read-only pointer to the start of the data in buf |
124 | */ | 124 | */ |
125 | const u_char *sshbuf_ptr(const struct sshbuf *buf); | 125 | const u_char *sshbuf_ptr(const struct sshbuf *buf); |
126 | 126 | ||
127 | /* | 127 | /* |
128 | * Returns a mutable pointer to the start of the the data in buf, or | 128 | * Returns a mutable pointer to the start of the data in buf, or |
129 | * NULL if the buffer is read-only. | 129 | * NULL if the buffer is read-only. |
130 | */ | 130 | */ |
131 | u_char *sshbuf_mutable_ptr(const struct sshbuf *buf); | 131 | u_char *sshbuf_mutable_ptr(const struct sshbuf *buf); |
@@ -241,45 +241,48 @@ int sshbuf_b64tod(struct sshbuf *buf, const char *b64); | |||
241 | 241 | ||
242 | /* Macros for decoding/encoding integers */ | 242 | /* Macros for decoding/encoding integers */ |
243 | #define PEEK_U64(p) \ | 243 | #define PEEK_U64(p) \ |
244 | (((u_int64_t)(((u_char *)(p))[0]) << 56) | \ | 244 | (((u_int64_t)(((const u_char *)(p))[0]) << 56) | \ |
245 | ((u_int64_t)(((u_char *)(p))[1]) << 48) | \ | 245 | ((u_int64_t)(((const u_char *)(p))[1]) << 48) | \ |
246 | ((u_int64_t)(((u_char *)(p))[2]) << 40) | \ | 246 | ((u_int64_t)(((const u_char *)(p))[2]) << 40) | \ |
247 | ((u_int64_t)(((u_char *)(p))[3]) << 32) | \ | 247 | ((u_int64_t)(((const u_char *)(p))[3]) << 32) | \ |
248 | ((u_int64_t)(((u_char *)(p))[4]) << 24) | \ | 248 | ((u_int64_t)(((const u_char *)(p))[4]) << 24) | \ |
249 | ((u_int64_t)(((u_char *)(p))[5]) << 16) | \ | 249 | ((u_int64_t)(((const u_char *)(p))[5]) << 16) | \ |
250 | ((u_int64_t)(((u_char *)(p))[6]) << 8) | \ | 250 | ((u_int64_t)(((const u_char *)(p))[6]) << 8) | \ |
251 | (u_int64_t)(((u_char *)(p))[7])) | 251 | (u_int64_t)(((const u_char *)(p))[7])) |
252 | #define PEEK_U32(p) \ | 252 | #define PEEK_U32(p) \ |
253 | (((u_int32_t)(((u_char *)(p))[0]) << 24) | \ | 253 | (((u_int32_t)(((const u_char *)(p))[0]) << 24) | \ |
254 | ((u_int32_t)(((u_char *)(p))[1]) << 16) | \ | 254 | ((u_int32_t)(((const u_char *)(p))[1]) << 16) | \ |
255 | ((u_int32_t)(((u_char *)(p))[2]) << 8) | \ | 255 | ((u_int32_t)(((const u_char *)(p))[2]) << 8) | \ |
256 | (u_int32_t)(((u_char *)(p))[3])) | 256 | (u_int32_t)(((const u_char *)(p))[3])) |
257 | #define PEEK_U16(p) \ | 257 | #define PEEK_U16(p) \ |
258 | (((u_int16_t)(((u_char *)(p))[0]) << 8) | \ | 258 | (((u_int16_t)(((const u_char *)(p))[0]) << 8) | \ |
259 | (u_int16_t)(((u_char *)(p))[1])) | 259 | (u_int16_t)(((const u_char *)(p))[1])) |
260 | 260 | ||
261 | #define POKE_U64(p, v) \ | 261 | #define POKE_U64(p, v) \ |
262 | do { \ | 262 | do { \ |
263 | ((u_char *)(p))[0] = (((u_int64_t)(v)) >> 56) & 0xff; \ | 263 | const u_int64_t __v = (v); \ |
264 | ((u_char *)(p))[1] = (((u_int64_t)(v)) >> 48) & 0xff; \ | 264 | ((u_char *)(p))[0] = (__v >> 56) & 0xff; \ |
265 | ((u_char *)(p))[2] = (((u_int64_t)(v)) >> 40) & 0xff; \ | 265 | ((u_char *)(p))[1] = (__v >> 48) & 0xff; \ |
266 | ((u_char *)(p))[3] = (((u_int64_t)(v)) >> 32) & 0xff; \ | 266 | ((u_char *)(p))[2] = (__v >> 40) & 0xff; \ |
267 | ((u_char *)(p))[4] = (((u_int64_t)(v)) >> 24) & 0xff; \ | 267 | ((u_char *)(p))[3] = (__v >> 32) & 0xff; \ |
268 | ((u_char *)(p))[5] = (((u_int64_t)(v)) >> 16) & 0xff; \ | 268 | ((u_char *)(p))[4] = (__v >> 24) & 0xff; \ |
269 | ((u_char *)(p))[6] = (((u_int64_t)(v)) >> 8) & 0xff; \ | 269 | ((u_char *)(p))[5] = (__v >> 16) & 0xff; \ |
270 | ((u_char *)(p))[7] = ((u_int64_t)(v)) & 0xff; \ | 270 | ((u_char *)(p))[6] = (__v >> 8) & 0xff; \ |
271 | ((u_char *)(p))[7] = __v & 0xff; \ | ||
271 | } while (0) | 272 | } while (0) |
272 | #define POKE_U32(p, v) \ | 273 | #define POKE_U32(p, v) \ |
273 | do { \ | 274 | do { \ |
274 | ((u_char *)(p))[0] = (((u_int64_t)(v)) >> 24) & 0xff; \ | 275 | const u_int32_t __v = (v); \ |
275 | ((u_char *)(p))[1] = (((u_int64_t)(v)) >> 16) & 0xff; \ | 276 | ((u_char *)(p))[0] = (__v >> 24) & 0xff; \ |
276 | ((u_char *)(p))[2] = (((u_int64_t)(v)) >> 8) & 0xff; \ | 277 | ((u_char *)(p))[1] = (__v >> 16) & 0xff; \ |
277 | ((u_char *)(p))[3] = ((u_int64_t)(v)) & 0xff; \ | 278 | ((u_char *)(p))[2] = (__v >> 8) & 0xff; \ |
279 | ((u_char *)(p))[3] = __v & 0xff; \ | ||
278 | } while (0) | 280 | } while (0) |
279 | #define POKE_U16(p, v) \ | 281 | #define POKE_U16(p, v) \ |
280 | do { \ | 282 | do { \ |
281 | ((u_char *)(p))[0] = (((u_int64_t)(v)) >> 8) & 0xff; \ | 283 | const u_int16_t __v = (v); \ |
282 | ((u_char *)(p))[1] = ((u_int64_t)(v)) & 0xff; \ | 284 | ((u_char *)(p))[0] = (__v >> 8) & 0xff; \ |
285 | ((u_char *)(p))[1] = __v & 0xff; \ | ||
283 | } while (0) | 286 | } while (0) |
284 | 287 | ||
285 | /* Internal definitions follow. Exposed for regress tests */ | 288 | /* Internal definitions follow. Exposed for regress tests */ |