Commit fdc0a767 authored by conrad's avatar conrad

be more robust against corrupt files in oggzinfo, oggz_tools.c


git-svn-id: http://svn.annodex.net/liboggz/trunk@2864 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4799541f
......@@ -211,15 +211,31 @@ static char *
ot_skeleton_info (unsigned char * data, long len)
{
char * buf;
double pres_n, pres_d, pres;
double base_n, base_d, base;
if (len < 64) return NULL;
if (len < 64L) return NULL;
buf = malloc (60);
pres_n = (double)INT64_LE_AT(&data[12]);
pres_d = (double)INT64_LE_AT(&data[20]);
if (pres_d != 0.0) {
pres = pres_n / pres_d;
} else {
pres = 0.0;
}
base_n = (double)INT64_LE_AT(&data[12]);
base_d = (double)INT64_LE_AT(&data[20]);
if (base_d != 0.0) {
base = base_n / base_d;
} else {
base = 0.0;
}
snprintf (buf, 60,
"\tPresentation-Time: %.3f\n\tBasetime: %.3f\n",
(double)INT64_LE_AT(&data[12]) / (double)INT64_LE_AT(&data[20]),
(double)INT64_LE_AT(&data[28]) / (double)INT64_LE_AT(&data[36]));
"\tPresentation-Time: %.3f\n\tBasetime: %.3f\n", pres, base);
return buf;
}
......@@ -253,6 +269,8 @@ ot_page_identify (OGGZ *oggz, const ogg_page * og, char ** info)
serial_no = ogg_page_serialno(og);
content = oggz_stream_get_content(oggz, serial_no);
if (content == OGGZ_ERR_BAD_SERIALNO) return NULL;
ret = oggz_stream_get_content_type(oggz, serial_no);
if (info != NULL)
......
......@@ -290,7 +290,11 @@ oit_print (OI_Info * info, OI_TrackInfo * oit, long serialno)
static void
oi_stats_average (OI_Stats * stats)
{
stats->length_avg = stats->length_total / stats->count;
if (stats->count > 0) {
stats->length_avg = stats->length_total / stats->count;
} else {
stats->length_avg = 0;
}
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment