diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-13 19:00:02 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-13 19:00:02 +0000 |
commit | ca694ec28d0a880346a6b76181fa7bfb88135de3 (patch) | |
tree | 31cd22cb159db7c7cdaba92da6fe20d7d4b91ce4 /funcs/func_env.c | |
parent | 0d2ab49caab01c31134ab5b021f4519630f21624 (diff) |
It really cannot fail in the places below, but the stupid compiler doesn't know that.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@276120 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_env.c')
-rw-r--r-- | funcs/func_env.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/funcs/func_env.c b/funcs/func_env.c index 24f76b316..c2fc746f5 100644 --- a/funcs/func_env.c +++ b/funcs/func_env.c @@ -498,7 +498,10 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru return 0; } - fseeko(ff, 0, SEEK_END); + if (fseeko(ff, 0, SEEK_END) < 0) { + ast_log(LOG_ERROR, "Cannot seek to end of '%s': %s\n", args.filename, strerror(errno)); + return -1; + } flength = ftello(ff); if (offset < 0) { @@ -573,6 +576,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru fclose(ff); return -1; } + flength = ftello(ff); if (length == LLONG_MAX) { @@ -876,8 +880,12 @@ static int file_write(struct ast_channel *chan, const char *cmd, char *data, con /* Write out the value, then write just up until where we last moved some data */ if (fwrite(value, 1, vlength, ff) < vlength) { ast_log(LOG_ERROR, "Short write?!!\n"); - } else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) { - ast_log(LOG_ERROR, "Short write?!!\n"); + } else { + off_t curpos = ftello(ff); + foplen = lastwritten - curpos; + if (fwrite(fbuf, 1, foplen, ff) < foplen) { + ast_log(LOG_ERROR, "Short write?!!\n"); + } } fclose(ff); } @@ -1153,8 +1161,12 @@ static int file_write(struct ast_channel *chan, const char *cmd, char *data, con ast_log(LOG_ERROR, "Short write?!!\n"); fclose(ff); return -1; - } else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) { - ast_log(LOG_ERROR, "Short write?!!\n"); + } else { + off_t curpos = ftello(ff); + foplen = lastwritten - curpos; + if (fwrite(fbuf, 1, foplen, ff) < foplen) { + ast_log(LOG_ERROR, "Short write?!!\n"); + } } fclose(ff); } |