X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=ogg_afh.c;h=b6132edf7bc3740c55836df48d62d66c9ee5609e;hb=3062b9da4f71ea236f46efda9a51add1b15cda1a;hp=11f7f5ad53a9a1f999fa7c7076d88df3aeb4407b;hpb=753b26859be2150d3f4e7840a86412f96f60627a;p=paraslash.git diff --git a/ogg_afh.c b/ogg_afh.c index 11f7f5ad..b6132edf 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -34,8 +34,15 @@ struct ogg_datasource { static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource) { struct ogg_datasource *ods = datasource; - size_t copy = PARA_MIN(ods->numbytes - ods->fpos, size * nmemb), - ret = copy / size; + size_t copy, ret; + + if (!size) + return 0; + + assert(ods->numbytes >= ods->fpos); + ret = ods->numbytes - ods->fpos; + copy = PARA_MIN(ret, size * nmemb); + ret = copy / size; if (!ret) return 0; memcpy(buf, ods->map + ods->fpos, copy); @@ -115,7 +122,7 @@ static int ogg_compute_header_len(char *map, size_t numbytes, struct afh_info *afhi) { int ret; - size_t len = PARA_MIN(numbytes, CHUNK_SIZE); + size_t len = PARA_MIN(numbytes, (size_t)CHUNK_SIZE); int serial; char *buf;