Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: fix some coverity issues
  • Loading branch information
perexg committed Oct 3, 2014
1 parent d3fcdf3 commit ab8f4bf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/timeshift/timeshift_reader.c
Expand Up @@ -52,8 +52,8 @@ static ssize_t _read_pktbuf ( int fd, pktbuf_t **pktbuf )
if (r != sizeof(sz)) return 0;
cnt += r;

/* Empty */
if (!sz) {
/* Empty And Sanity Check */
if (!sz || sz > 1024 * 1024) {
*pktbuf = NULL;
return cnt;
}
Expand Down Expand Up @@ -93,6 +93,9 @@ static ssize_t _read_msg ( int fd, streaming_message_t **sm )
/* EOF */
if (sz == 0) return cnt;

/* Wrong data size */
if (sz > 1024 * 1024) return -1;

/* Type */
r = read(fd, &type, sizeof(type));
if (r < 0) return -1;
Expand Down Expand Up @@ -320,10 +323,12 @@ static int _timeshift_read
if (*cur_file) {

/* Open file */
if (*fd == -1) {
if (*fd < 0) {
tvhtrace("timeshift", "ts %d open file %s",
ts->id, (*cur_file)->path);
*fd = open((*cur_file)->path, O_RDONLY);
if (*fd < 0)
return -1;
}
tvhtrace("timeshift", "ts %d seek to %jd", ts->id, (intmax_t)*cur_off);
lseek(*fd, *cur_off, SEEK_SET);
Expand Down

0 comments on commit ab8f4bf

Please sign in to comment.