aboutsummaryrefslogtreecommitdiff
path: root/cmd-load-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-05-21 19:38:51 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-05-21 19:38:51 +0000
commita8ec5f1d09205f5a699031271150f978ab711848 (patch)
tree5856eed0e7e641878a93a041414b4b2e7e3be1a1 /cmd-load-buffer.c
parenteb6007102e06fb70c251ade2fd34f50798ef6a13 (diff)
downloadrtmux-a8ec5f1d09205f5a699031271150f978ab711848.tar.gz
rtmux-a8ec5f1d09205f5a699031271150f978ab711848.tar.bz2
rtmux-a8ec5f1d09205f5a699031271150f978ab711848.zip
stat(2) files before trying to load them to avoid problems, for example with "source-file /dev/zero".
This commit dedicated to Tom: protecting idiots from their own stupidity for more than 20 years.
Diffstat (limited to 'cmd-load-buffer.c')
-rw-r--r--cmd-load-buffer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c
index fd3387b0..1be567ec 100644
--- a/cmd-load-buffer.c
+++ b/cmd-load-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-load-buffer.c,v 1.3 2009-05-18 16:22:30 nicm Exp $ */
+/* $Id: cmd-load-buffer.c,v 1.4 2009-05-21 19:38:51 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -62,6 +62,10 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
return (-1);
}
+ if (!S_ISREG(statbuf.st_mode)) {
+ ctx->error(ctx, "%s: not a regular file", data->arg);
+ return (-1);
+ }
if ((f = fopen(data->arg, "rb")) == NULL) {
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));