/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
/**
#include <config.h>
#endif
+#include <limits.h>
#include <stdlib.h>
#include "odr-priv.h"
#include <yaz/xmalloc.h>
int odr_write(ODR o, const char *buf, int bytes)
{
+ if (bytes < 0 || o->op->pos > INT_MAX - bytes)
+ {
+ odr_seterror(o, OSPACE, 40);
+ return -1;
+ }
if (o->op->pos + bytes >= o->op->size && odr_grow_block(o, bytes))
{
odr_seterror(o, OSPACE, 40);