txrx-vchan: guard against invalid buffer sizes from libvchan

These APIs can now return -1 when invalid indices are detected.
release2 mm_f7e943f7
Vincent Penquerc'h 10 years ago committed by Marek Marczykowski-Górecki
parent b51435c903
commit f7e943f7ec

@ -73,12 +73,22 @@ int read_all_vchan_ext(void *buf, int size)
int read_ready_vchan_ext()
{
return libvchan_data_ready(ctrl);
int ready = libvchan_data_ready(ctrl);
if (ready < 0) {
fprintf(stderr, "libvchan_data_ready returned invalid size\n");
exit(1);
}
return ready;
}
int buffer_space_vchan_ext()
{
return libvchan_buffer_space(ctrl);
int space = libvchan_buffer_space(ctrl);
if (space < 0) {
fprintf(stderr, "libvchan_buffer_space returned invalid size\n");
exit(1);
}
return space;
}
// if the remote domain is destroyed, we get no notification

Loading…
Cancel
Save