Sync OpenBSD patchset 318:

Give each paste buffer a size member instead of requiring them to be
zero-terminated.
This commit is contained in:
Tiago Cunha
2009-09-07 23:48:54 +00:00
parent 5edc465802
commit c272de7cba
11 changed files with 73 additions and 59 deletions

View File

@ -1,4 +1,4 @@
/* $Id: paste.c,v 1.8 2009-07-31 20:33:49 tcunha Exp $ */
/* $Id: paste.c,v 1.9 2009-09-07 23:48:54 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -97,7 +97,7 @@ paste_free_index(struct paste_stack *ps, u_int idx)
}
void
paste_add(struct paste_stack *ps, char *data, u_int limit)
paste_add(struct paste_stack *ps, u_char *data, size_t size, u_int limit)
{
struct paste_buffer *pb;
@ -115,12 +115,13 @@ paste_add(struct paste_stack *ps, char *data, u_int limit)
ARRAY_INSERT(ps, 0, pb);
pb->data = data;
pb->size = size;
if (gettimeofday(&pb->tv, NULL) != 0)
fatal("gettimeofday");
}
int
paste_replace(struct paste_stack *ps, u_int idx, char *data)
paste_replace(struct paste_stack *ps, u_int idx, u_char *data, size_t size)
{
struct paste_buffer *pb;
@ -131,6 +132,7 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data)
xfree(pb->data);
pb->data = data;
pb->size = size;
if (gettimeofday(&pb->tv, NULL) != 0)
fatal("gettimeofday");