summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--mac.c6
-rw-r--r--monitor_mm.c29
-rw-r--r--monitor_mm.h4
-rw-r--r--xmalloc.c12
5 files changed, 32 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index c429c3b8a..ab584d993 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
120140110
2 - (djm) OpenBSD CVS Sync
3 - tedu@cvs.openbsd.org 2014/01/04 17:50:55
4 [mac.c monitor_mm.c monitor_mm.h xmalloc.c]
5 use standard types and formats for size_t like variables. ok dtucker
6
120140108 720140108
2 - (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@ 8 - (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@
3 9
diff --git a/mac.c b/mac.c
index c71b6a741..d3a0b935f 100644
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mac.c,v 1.25 2013/11/07 11:58:27 dtucker Exp $ */ 1/* $OpenBSD: mac.c,v 1.26 2014/01/04 17:50:55 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -181,8 +181,8 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
181 u_char b[4], nonce[8]; 181 u_char b[4], nonce[8];
182 182
183 if (mac->mac_len > sizeof(u)) 183 if (mac->mac_len > sizeof(u))
184 fatal("mac_compute: mac too long %u %lu", 184 fatal("mac_compute: mac too long %u %zu",
185 mac->mac_len, (u_long)sizeof(u)); 185 mac->mac_len, sizeof(u));
186 186
187 switch (mac->type) { 187 switch (mac->type) {
188 case SSH_EVP: 188 case SSH_EVP:
diff --git a/monitor_mm.c b/monitor_mm.c
index d3e6aeee5..0ba0658a1 100644
--- a/monitor_mm.c
+++ b/monitor_mm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_mm.c,v 1.18 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: monitor_mm.c,v 1.19 2014/01/04 17:50:55 tedu Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * All rights reserved. 4 * All rights reserved.
@@ -35,6 +35,7 @@
35 35
36#include <errno.h> 36#include <errno.h>
37#include <stdarg.h> 37#include <stdarg.h>
38#include <stddef.h>
38#include <stdlib.h> 39#include <stdlib.h>
39#include <string.h> 40#include <string.h>
40 41
@@ -46,7 +47,7 @@
46static int 47static int
47mm_compare(struct mm_share *a, struct mm_share *b) 48mm_compare(struct mm_share *a, struct mm_share *b)
48{ 49{
49 long diff = (char *)a->address - (char *)b->address; 50 ptrdiff_t diff = (char *)a->address - (char *)b->address;
50 51
51 if (diff == 0) 52 if (diff == 0)
52 return (0); 53 return (0);
@@ -73,8 +74,8 @@ mm_make_entry(struct mm_master *mm, struct mmtree *head,
73 74
74 tmp2 = RB_INSERT(mmtree, head, tmp); 75 tmp2 = RB_INSERT(mmtree, head, tmp);
75 if (tmp2 != NULL) 76 if (tmp2 != NULL)
76 fatal("mm_make_entry(%p): double address %p->%p(%lu)", 77 fatal("mm_make_entry(%p): double address %p->%p(%zu)",
77 mm, tmp2, address, (u_long)size); 78 mm, tmp2, address, size);
78 79
79 return (tmp); 80 return (tmp);
80} 81}
@@ -101,7 +102,7 @@ mm_create(struct mm_master *mmalloc, size_t size)
101 102
102 address = xmmap(size); 103 address = xmmap(size);
103 if (address == (void *)MAP_FAILED) 104 if (address == (void *)MAP_FAILED)
104 fatal("mmap(%lu): %s", (u_long)size, strerror(errno)); 105 fatal("mmap(%zu): %s", size, strerror(errno));
105 106
106 mm->address = address; 107 mm->address = address;
107 mm->size = size; 108 mm->size = size;
@@ -141,7 +142,7 @@ mm_destroy(struct mm_master *mm)
141 142
142#ifdef HAVE_MMAP 143#ifdef HAVE_MMAP
143 if (munmap(mm->address, mm->size) == -1) 144 if (munmap(mm->address, mm->size) == -1)
144 fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size, 145 fatal("munmap(%p, %zu): %s", mm->address, mm->size,
145 strerror(errno)); 146 strerror(errno));
146#else 147#else
147 fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported", 148 fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported",
@@ -160,7 +161,7 @@ mm_xmalloc(struct mm_master *mm, size_t size)
160 161
161 address = mm_malloc(mm, size); 162 address = mm_malloc(mm, size);
162 if (address == NULL) 163 if (address == NULL)
163 fatal("%s: mm_malloc(%lu)", __func__, (u_long)size); 164 fatal("%s: mm_malloc(%zu)", __func__, size);
164 memset(address, 0, size); 165 memset(address, 0, size);
165 return (address); 166 return (address);
166} 167}
@@ -195,7 +196,7 @@ mm_malloc(struct mm_master *mm, size_t size)
195 196
196 /* Does not change order in RB tree */ 197 /* Does not change order in RB tree */
197 mms->size -= size; 198 mms->size -= size;
198 mms->address = (u_char *)mms->address + size; 199 mms->address = (char *)mms->address + size;
199 200
200 if (mms->size == 0) { 201 if (mms->size == 0) {
201 RB_REMOVE(mmtree, &mm->rb_free, mms); 202 RB_REMOVE(mmtree, &mm->rb_free, mms);
@@ -248,8 +249,8 @@ mm_free(struct mm_master *mm, void *address)
248 249
249 /* Check if range does not overlap */ 250 /* Check if range does not overlap */
250 if (prev != NULL && MM_ADDRESS_END(prev) > address) 251 if (prev != NULL && MM_ADDRESS_END(prev) > address)
251 fatal("mm_free: memory corruption: %p(%lu) > %p", 252 fatal("mm_free: memory corruption: %p(%zu) > %p",
252 prev->address, (u_long)prev->size, address); 253 prev->address, prev->size, address);
253 254
254 /* See if we can merge backwards */ 255 /* See if we can merge backwards */
255 if (prev != NULL && MM_ADDRESS_END(prev) == address) { 256 if (prev != NULL && MM_ADDRESS_END(prev) == address) {
@@ -271,8 +272,8 @@ mm_free(struct mm_master *mm, void *address)
271 return; 272 return;
272 273
273 if (MM_ADDRESS_END(prev) > mms->address) 274 if (MM_ADDRESS_END(prev) > mms->address)
274 fatal("mm_free: memory corruption: %p < %p(%lu)", 275 fatal("mm_free: memory corruption: %p < %p(%zu)",
275 mms->address, prev->address, (u_long)prev->size); 276 mms->address, prev->address, prev->size);
276 if (MM_ADDRESS_END(prev) != mms->address) 277 if (MM_ADDRESS_END(prev) != mms->address)
277 return; 278 return;
278 279
@@ -343,12 +344,12 @@ mm_share_sync(struct mm_master **pmm, struct mm_master **pmmalloc)
343void 344void
344mm_memvalid(struct mm_master *mm, void *address, size_t size) 345mm_memvalid(struct mm_master *mm, void *address, size_t size)
345{ 346{
346 void *end = (u_char *)address + size; 347 void *end = (char *)address + size;
347 348
348 if (address < mm->address) 349 if (address < mm->address)
349 fatal("mm_memvalid: address too small: %p", address); 350 fatal("mm_memvalid: address too small: %p", address);
350 if (end < address) 351 if (end < address)
351 fatal("mm_memvalid: end < address: %p < %p", end, address); 352 fatal("mm_memvalid: end < address: %p < %p", end, address);
352 if (end > (void *)((u_char *)mm->address + mm->size)) 353 if (end > MM_ADDRESS_END(mm))
353 fatal("mm_memvalid: address too large: %p", address); 354 fatal("mm_memvalid: address too large: %p", address);
354} 355}
diff --git a/monitor_mm.h b/monitor_mm.h
index c890f7709..f1fae7e3b 100644
--- a/monitor_mm.h
+++ b/monitor_mm.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_mm.h,v 1.5 2008/04/29 11:20:31 otto Exp $ */ 1/* $OpenBSD: monitor_mm.h,v 1.6 2014/01/04 17:50:55 tedu Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 4 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
@@ -47,7 +47,7 @@ RB_PROTOTYPE(mmtree, mm_share, next, mm_compare)
47 47
48#define MM_MINSIZE 128 48#define MM_MINSIZE 128
49 49
50#define MM_ADDRESS_END(x) (void *)((u_char *)(x)->address + (x)->size) 50#define MM_ADDRESS_END(x) (void *)((char *)(x)->address + (x)->size)
51 51
52struct mm_master *mm_create(struct mm_master *, size_t); 52struct mm_master *mm_create(struct mm_master *, size_t);
53void mm_destroy(struct mm_master *); 53void mm_destroy(struct mm_master *);
diff --git a/xmalloc.c b/xmalloc.c
index 92f781fd0..2f1cd2306 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.28 2013/05/17 00:13:14 djm Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -33,7 +33,7 @@ xmalloc(size_t size)
33 fatal("xmalloc: zero size"); 33 fatal("xmalloc: zero size");
34 ptr = malloc(size); 34 ptr = malloc(size);
35 if (ptr == NULL) 35 if (ptr == NULL)
36 fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size); 36 fatal("xmalloc: out of memory (allocating %zu bytes)", size);
37 return ptr; 37 return ptr;
38} 38}
39 39
@@ -48,8 +48,8 @@ xcalloc(size_t nmemb, size_t size)
48 fatal("xcalloc: nmemb * size > SIZE_T_MAX"); 48 fatal("xcalloc: nmemb * size > SIZE_T_MAX");
49 ptr = calloc(nmemb, size); 49 ptr = calloc(nmemb, size);
50 if (ptr == NULL) 50 if (ptr == NULL)
51 fatal("xcalloc: out of memory (allocating %lu bytes)", 51 fatal("xcalloc: out of memory (allocating %zu bytes)",
52 (u_long)(size * nmemb)); 52 size * nmemb);
53 return ptr; 53 return ptr;
54} 54}
55 55
@@ -68,8 +68,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
68 else 68 else
69 new_ptr = realloc(ptr, new_size); 69 new_ptr = realloc(ptr, new_size);
70 if (new_ptr == NULL) 70 if (new_ptr == NULL)
71 fatal("xrealloc: out of memory (new_size %lu bytes)", 71 fatal("xrealloc: out of memory (new_size %zu bytes)",
72 (u_long) new_size); 72 new_size);
73 return new_ptr; 73 return new_ptr;
74} 74}
75 75