mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-01-03 08:12:05 +00:00
- tedu@cvs.openbsd.org 2014/01/04 17:50:55
[mac.c monitor_mm.c monitor_mm.h xmalloc.c] use standard types and formats for size_t like variables. ok dtucker
This commit is contained in:
parent
a9c1e500ef
commit
3e49853650
@ -1,3 +1,9 @@
|
|||||||
|
20140110
|
||||||
|
- (djm) OpenBSD CVS Sync
|
||||||
|
- tedu@cvs.openbsd.org 2014/01/04 17:50:55
|
||||||
|
[mac.c monitor_mm.c monitor_mm.h xmalloc.c]
|
||||||
|
use standard types and formats for size_t like variables. ok dtucker
|
||||||
|
|
||||||
20140108
|
20140108
|
||||||
- (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@
|
- (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@
|
||||||
|
|
||||||
|
6
mac.c
6
mac.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: mac.c,v 1.25 2013/11/07 11:58:27 dtucker Exp $ */
|
/* $OpenBSD: mac.c,v 1.26 2014/01/04 17:50:55 tedu Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
@ -181,8 +181,8 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
|
|||||||
u_char b[4], nonce[8];
|
u_char b[4], nonce[8];
|
||||||
|
|
||||||
if (mac->mac_len > sizeof(u))
|
if (mac->mac_len > sizeof(u))
|
||||||
fatal("mac_compute: mac too long %u %lu",
|
fatal("mac_compute: mac too long %u %zu",
|
||||||
mac->mac_len, (u_long)sizeof(u));
|
mac->mac_len, sizeof(u));
|
||||||
|
|
||||||
switch (mac->type) {
|
switch (mac->type) {
|
||||||
case SSH_EVP:
|
case SSH_EVP:
|
||||||
|
29
monitor_mm.c
29
monitor_mm.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: monitor_mm.c,v 1.18 2013/11/08 00:39:15 djm Exp $ */
|
/* $OpenBSD: monitor_mm.c,v 1.19 2014/01/04 17:50:55 tedu Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -46,7 +47,7 @@
|
|||||||
static int
|
static int
|
||||||
mm_compare(struct mm_share *a, struct mm_share *b)
|
mm_compare(struct mm_share *a, struct mm_share *b)
|
||||||
{
|
{
|
||||||
long diff = (char *)a->address - (char *)b->address;
|
ptrdiff_t diff = (char *)a->address - (char *)b->address;
|
||||||
|
|
||||||
if (diff == 0)
|
if (diff == 0)
|
||||||
return (0);
|
return (0);
|
||||||
@ -73,8 +74,8 @@ mm_make_entry(struct mm_master *mm, struct mmtree *head,
|
|||||||
|
|
||||||
tmp2 = RB_INSERT(mmtree, head, tmp);
|
tmp2 = RB_INSERT(mmtree, head, tmp);
|
||||||
if (tmp2 != NULL)
|
if (tmp2 != NULL)
|
||||||
fatal("mm_make_entry(%p): double address %p->%p(%lu)",
|
fatal("mm_make_entry(%p): double address %p->%p(%zu)",
|
||||||
mm, tmp2, address, (u_long)size);
|
mm, tmp2, address, size);
|
||||||
|
|
||||||
return (tmp);
|
return (tmp);
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ mm_create(struct mm_master *mmalloc, size_t size)
|
|||||||
|
|
||||||
address = xmmap(size);
|
address = xmmap(size);
|
||||||
if (address == (void *)MAP_FAILED)
|
if (address == (void *)MAP_FAILED)
|
||||||
fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
|
fatal("mmap(%zu): %s", size, strerror(errno));
|
||||||
|
|
||||||
mm->address = address;
|
mm->address = address;
|
||||||
mm->size = size;
|
mm->size = size;
|
||||||
@ -141,7 +142,7 @@ mm_destroy(struct mm_master *mm)
|
|||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
if (munmap(mm->address, mm->size) == -1)
|
if (munmap(mm->address, mm->size) == -1)
|
||||||
fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size,
|
fatal("munmap(%p, %zu): %s", mm->address, mm->size,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
#else
|
#else
|
||||||
fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported",
|
fatal("%s: UsePrivilegeSeparation=yes and Compression=yes not supported",
|
||||||
@ -160,7 +161,7 @@ mm_xmalloc(struct mm_master *mm, size_t size)
|
|||||||
|
|
||||||
address = mm_malloc(mm, size);
|
address = mm_malloc(mm, size);
|
||||||
if (address == NULL)
|
if (address == NULL)
|
||||||
fatal("%s: mm_malloc(%lu)", __func__, (u_long)size);
|
fatal("%s: mm_malloc(%zu)", __func__, size);
|
||||||
memset(address, 0, size);
|
memset(address, 0, size);
|
||||||
return (address);
|
return (address);
|
||||||
}
|
}
|
||||||
@ -195,7 +196,7 @@ mm_malloc(struct mm_master *mm, size_t size)
|
|||||||
|
|
||||||
/* Does not change order in RB tree */
|
/* Does not change order in RB tree */
|
||||||
mms->size -= size;
|
mms->size -= size;
|
||||||
mms->address = (u_char *)mms->address + size;
|
mms->address = (char *)mms->address + size;
|
||||||
|
|
||||||
if (mms->size == 0) {
|
if (mms->size == 0) {
|
||||||
RB_REMOVE(mmtree, &mm->rb_free, mms);
|
RB_REMOVE(mmtree, &mm->rb_free, mms);
|
||||||
@ -248,8 +249,8 @@ mm_free(struct mm_master *mm, void *address)
|
|||||||
|
|
||||||
/* Check if range does not overlap */
|
/* Check if range does not overlap */
|
||||||
if (prev != NULL && MM_ADDRESS_END(prev) > address)
|
if (prev != NULL && MM_ADDRESS_END(prev) > address)
|
||||||
fatal("mm_free: memory corruption: %p(%lu) > %p",
|
fatal("mm_free: memory corruption: %p(%zu) > %p",
|
||||||
prev->address, (u_long)prev->size, address);
|
prev->address, prev->size, address);
|
||||||
|
|
||||||
/* See if we can merge backwards */
|
/* See if we can merge backwards */
|
||||||
if (prev != NULL && MM_ADDRESS_END(prev) == address) {
|
if (prev != NULL && MM_ADDRESS_END(prev) == address) {
|
||||||
@ -271,8 +272,8 @@ mm_free(struct mm_master *mm, void *address)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (MM_ADDRESS_END(prev) > mms->address)
|
if (MM_ADDRESS_END(prev) > mms->address)
|
||||||
fatal("mm_free: memory corruption: %p < %p(%lu)",
|
fatal("mm_free: memory corruption: %p < %p(%zu)",
|
||||||
mms->address, prev->address, (u_long)prev->size);
|
mms->address, prev->address, prev->size);
|
||||||
if (MM_ADDRESS_END(prev) != mms->address)
|
if (MM_ADDRESS_END(prev) != mms->address)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -343,12 +344,12 @@ mm_share_sync(struct mm_master **pmm, struct mm_master **pmmalloc)
|
|||||||
void
|
void
|
||||||
mm_memvalid(struct mm_master *mm, void *address, size_t size)
|
mm_memvalid(struct mm_master *mm, void *address, size_t size)
|
||||||
{
|
{
|
||||||
void *end = (u_char *)address + size;
|
void *end = (char *)address + size;
|
||||||
|
|
||||||
if (address < mm->address)
|
if (address < mm->address)
|
||||||
fatal("mm_memvalid: address too small: %p", address);
|
fatal("mm_memvalid: address too small: %p", address);
|
||||||
if (end < address)
|
if (end < address)
|
||||||
fatal("mm_memvalid: end < address: %p < %p", end, address);
|
fatal("mm_memvalid: end < address: %p < %p", end, address);
|
||||||
if (end > (void *)((u_char *)mm->address + mm->size))
|
if (end > MM_ADDRESS_END(mm))
|
||||||
fatal("mm_memvalid: address too large: %p", address);
|
fatal("mm_memvalid: address too large: %p", address);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: monitor_mm.h,v 1.5 2008/04/29 11:20:31 otto Exp $ */
|
/* $OpenBSD: monitor_mm.h,v 1.6 2014/01/04 17:50:55 tedu Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||||
@ -47,7 +47,7 @@ RB_PROTOTYPE(mmtree, mm_share, next, mm_compare)
|
|||||||
|
|
||||||
#define MM_MINSIZE 128
|
#define MM_MINSIZE 128
|
||||||
|
|
||||||
#define MM_ADDRESS_END(x) (void *)((u_char *)(x)->address + (x)->size)
|
#define MM_ADDRESS_END(x) (void *)((char *)(x)->address + (x)->size)
|
||||||
|
|
||||||
struct mm_master *mm_create(struct mm_master *, size_t);
|
struct mm_master *mm_create(struct mm_master *, size_t);
|
||||||
void mm_destroy(struct mm_master *);
|
void mm_destroy(struct mm_master *);
|
||||||
|
12
xmalloc.c
12
xmalloc.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: xmalloc.c,v 1.28 2013/05/17 00:13:14 djm Exp $ */
|
/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
@ -33,7 +33,7 @@ xmalloc(size_t size)
|
|||||||
fatal("xmalloc: zero size");
|
fatal("xmalloc: zero size");
|
||||||
ptr = malloc(size);
|
ptr = malloc(size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size);
|
fatal("xmalloc: out of memory (allocating %zu bytes)", size);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ xcalloc(size_t nmemb, size_t size)
|
|||||||
fatal("xcalloc: nmemb * size > SIZE_T_MAX");
|
fatal("xcalloc: nmemb * size > SIZE_T_MAX");
|
||||||
ptr = calloc(nmemb, size);
|
ptr = calloc(nmemb, size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
fatal("xcalloc: out of memory (allocating %lu bytes)",
|
fatal("xcalloc: out of memory (allocating %zu bytes)",
|
||||||
(u_long)(size * nmemb));
|
size * nmemb);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +68,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
|
|||||||
else
|
else
|
||||||
new_ptr = realloc(ptr, new_size);
|
new_ptr = realloc(ptr, new_size);
|
||||||
if (new_ptr == NULL)
|
if (new_ptr == NULL)
|
||||||
fatal("xrealloc: out of memory (new_size %lu bytes)",
|
fatal("xrealloc: out of memory (new_size %zu bytes)",
|
||||||
(u_long) new_size);
|
new_size);
|
||||||
return new_ptr;
|
return new_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user