Call fstat() after fopen() rather than stat() before.

pull/1/head
Nicholas Marriott 2009-10-26 21:25:57 +00:00
parent 539c73bdb1
commit 6b804f3a4a
1 changed files with 3 additions and 2 deletions

View File

@ -56,13 +56,14 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
if (stat(data->arg, &sb) < 0) {
if ((f = fopen(data->arg, "rb")) == NULL) {
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
return (-1);
}
if ((f = fopen(data->arg, "rb")) == NULL) {
if (fstat(fileno(f), &sb) < 0) {
ctx->error(ctx, "%s: %s", data->arg, strerror(errno));
fclose(f);
return (-1);
}