On Thu, Jul 10, 2014 at 11:51 AM, Ruoyu <lian...@ucweb.com> wrote: > If epoch file length is shorter than size of time due to file broken, > epoch_stat.st_size - sizeof(*timestamp) is negative. However, > the third parameter of function xread will get it as type size_t, > then xread will think there are many data to be read. Therefore, > a file length checking to prevent this situation is needed. > > Signed-off-by: Ruoyu <lian...@ucweb.com> > --- > sheep/store.c | 5 +++++ > 1 file changed, 5 insertions(+)
Looks good to me. Could you rebase it on the latest master? Thanks, Hitoshi > > diff --git a/sheep/store.c b/sheep/store.c > index 87913d4..befcd13 100644 > --- a/sheep/store.c > +++ b/sheep/store.c > @@ -71,6 +71,11 @@ static int do_epoch_log_read(uint32_t epoch, struct > sd_node *nodes, int len, > goto err; > } > > + if (epoch_stat.st_size < sizeof(*timestamp)) { > + sd_err("invalid epoch %"PRIu32" log", epoch); > + goto err; > + } > + > if (len < epoch_stat.st_size - sizeof(*timestamp)) { > close(fd); > return -2; > -- > 1.8.3.2 > > > -- > sheepdog mailing list > sheepdog@lists.wpkg.org > http://lists.wpkg.org/mailman/listinfo/sheepdog -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog