X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=blobdiff_plain;f=lib.c;h=7a22d19eae1e96a29dd9214447f33e1024b8418b;hp=6c3cd0aff62924cd3e98449ae30616b54ce164a4;hb=7bc3c582a0a80d34d2c9c86ed9a588b3983e0db1;hpb=9f56f874416db295bdb50d448bd99cdd34db969d diff --git a/lib.c b/lib.c index 6c3cd0a..7a22d19 100644 --- a/lib.c +++ b/lib.c @@ -2,7 +2,7 @@ * userv - lib.c * useful utility routines, used in daemon, but not very dependent on it * - * Copyright (C)1996-1997 Ian Jackson + * Copyright (C)1996-1997,1999 Ian Jackson * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by @@ -25,8 +25,10 @@ #include #include #include +#include #include "config.h" +#include "common.h" #include "lib.h" char *xstrcat3save(const char *a, const char *b, const char *c) { @@ -67,10 +69,12 @@ void *xrealloc(void *p, size_t s) { return p; } -void makeroom(char **buffer, int *size, int needed) { - if (*size >= needed) return; +int makeroom(char **buffer, int *size, int needed) { + if (needed > MAX_GENERAL_STRING) return -1; + if (*size >= needed) return 0; *buffer= xrealloc(*buffer,needed); *size= needed; + return 0; } void vsnyprintf(char *buffer, size_t size, const char *fmt, va_list al) {