mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Merge "func_env: Prevent FILE() from reading garbage at end-of-file" into 13
This commit is contained in:
@@ -711,12 +711,13 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
|
|||||||
ast_debug(3, "offset=%" PRId64 ", length=%" PRId64 ", offset_offset=%" PRId64 ", length_offset=%" PRId64 "\n", offset, length, offset_offset, length_offset);
|
ast_debug(3, "offset=%" PRId64 ", length=%" PRId64 ", offset_offset=%" PRId64 ", length_offset=%" PRId64 "\n", offset, length, offset_offset, length_offset);
|
||||||
for (i = offset_offset; i < flength; i += sizeof(fbuf)) {
|
for (i = offset_offset; i < flength; i += sizeof(fbuf)) {
|
||||||
char *pos;
|
char *pos;
|
||||||
if (fread(fbuf, 1, sizeof(fbuf), ff) < sizeof(fbuf) && !feof(ff)) {
|
size_t bytes_read;
|
||||||
|
if ((bytes_read = fread(fbuf, 1, sizeof(fbuf), ff)) < sizeof(fbuf) && !feof(ff)) {
|
||||||
ast_log(LOG_ERROR, "Short read?!!\n");
|
ast_log(LOG_ERROR, "Short read?!!\n");
|
||||||
fclose(ff);
|
fclose(ff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (pos = fbuf; pos < fbuf + sizeof(fbuf); pos++) {
|
for (pos = fbuf; pos < fbuf + bytes_read; pos++) {
|
||||||
LINE_COUNTER(pos, format, current_length);
|
LINE_COUNTER(pos, format, current_length);
|
||||||
|
|
||||||
if (current_length == length) {
|
if (current_length == length) {
|
||||||
|
Reference in New Issue
Block a user