--- a/ucx/buffer.c Sat Oct 28 15:25:17 2017 +0200 +++ b/ucx/buffer.c Sat Oct 28 16:50:03 2017 +0200 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2016 Olaf Wintermann. All rights reserved. + * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "buffer.h" +#include "ucx/buffer.h" + #include <stdarg.h> #include <stdlib.h> #include <string.h> @@ -64,8 +65,9 @@ UcxBuffer* ucx_buffer_extract( UcxBuffer *src, size_t start, size_t length, int flags) { - - if (src->size == 0 || length == 0 || start+length > src->capacity) { + if (src->size == 0 || length == 0 || + ((size_t)-1) - start < length || start+length > src->capacity) + { return NULL; } @@ -150,7 +152,6 @@ size_t ucx_buffer_write(const void *ptr, size_t size, size_t nitems, UcxBuffer *buffer) { size_t len = size * nitems; - const char *string = ptr; size_t required = buffer->pos + len; if (buffer->pos > required) { return 0;