mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
It really cannot fail in the places below, but the stupid compiler doesn't know that.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@276120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -498,7 +498,10 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
return 0;
|
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);
|
flength = ftello(ff);
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
@@ -573,6 +576,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
fclose(ff);
|
fclose(ff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flength = ftello(ff);
|
flength = ftello(ff);
|
||||||
|
|
||||||
if (length == LLONG_MAX) {
|
if (length == LLONG_MAX) {
|
||||||
@@ -876,9 +880,13 @@ 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 */
|
/* Write out the value, then write just up until where we last moved some data */
|
||||||
if (fwrite(value, 1, vlength, ff) < vlength) {
|
if (fwrite(value, 1, vlength, ff) < vlength) {
|
||||||
ast_log(LOG_ERROR, "Short write?!!\n");
|
ast_log(LOG_ERROR, "Short write?!!\n");
|
||||||
} else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) {
|
} else {
|
||||||
|
off_t curpos = ftello(ff);
|
||||||
|
foplen = lastwritten - curpos;
|
||||||
|
if (fwrite(fbuf, 1, foplen, ff) < foplen) {
|
||||||
ast_log(LOG_ERROR, "Short write?!!\n");
|
ast_log(LOG_ERROR, "Short write?!!\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fclose(ff);
|
fclose(ff);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1153,9 +1161,13 @@ static int file_write(struct ast_channel *chan, const char *cmd, char *data, con
|
|||||||
ast_log(LOG_ERROR, "Short write?!!\n");
|
ast_log(LOG_ERROR, "Short write?!!\n");
|
||||||
fclose(ff);
|
fclose(ff);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (fwrite(fbuf, 1, (foplen = lastwritten - ftello(ff)), ff) < foplen) {
|
} else {
|
||||||
|
off_t curpos = ftello(ff);
|
||||||
|
foplen = lastwritten - curpos;
|
||||||
|
if (fwrite(fbuf, 1, foplen, ff) < foplen) {
|
||||||
ast_log(LOG_ERROR, "Short write?!!\n");
|
ast_log(LOG_ERROR, "Short write?!!\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fclose(ff);
|
fclose(ff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user