X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/f3143629476bae20f5310bbc0a59fe735b5d245d..a241edc87bed49d6bc5dc3c4c99786a921ae7c8a:/charfuncs.c diff --git a/charfuncs.c b/charfuncs.c index fea0a99..fab53a2 100644 --- a/charfuncs.c +++ b/charfuncs.c @@ -1,9 +1,20 @@ /* * charfuncs.c - Routines for dealing with character streams. * - * Jonathan McDowell + * Copyright 2002 Jonathan McDowell * - * Copyright 2002 Project Purple + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include @@ -25,11 +36,15 @@ int buffer_fetchchar(void *ctx, size_t count, void *c) struct buffer_ctx *buf = NULL; buf = (struct buffer_ctx *) ctx; + + if (buf->offset + count > buf->size) { + return 1; + } memcpy(c, &buf->buffer[buf->offset], count); buf->offset += count; - return (((buf->offset) == (buf->size)) ? 1 : 0); + return 0; } /**