Sync OpenBSD patchset 570:

Change paranoia check to check for <= 0 and to avoid warning.
pull/1/head
Tiago Cunha 2009-11-28 14:55:22 +00:00
parent fabf40b3b3
commit 91cf94b34b
1 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-load-buffer.c,v 1.13 2009-11-28 14:54:12 tcunha Exp $ */
/* $Id: cmd-load-buffer.c,v 1.14 2009-11-28 14:55:22 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@ -66,8 +66,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
goto error;
}
if (sb.st_size > SIZE_MAX) {
ctx->error(ctx, "%s: file too large", data->arg);
if (sb.st_size <= 0 || (uintmax_t) sb.st_size > SIZE_MAX) {
ctx->error(ctx, "%s: file empty or too large", data->arg);
goto error;
}
psize = (size_t) sb.st_size;