diff options
author | Thomas White <taw@physics.org> | 2017-05-09 17:03:16 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-05-09 17:03:16 +0200 |
commit | 66dc7ec0acff10d6f22cb9422bb430018d31722e (patch) | |
tree | b08d5b4912e37241f8748592f2bb8ec9361e9348 /libcrystfel/src/image.c | |
parent | cdd75c7fadfcd2dadee101611a00dcf0d0e6ec5c (diff) |
Add missing checks
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r-- | libcrystfel/src/image.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index c03b60d8..ef04cbf9 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -424,7 +424,8 @@ static char *cbf_strerr(int e) } -static int unpack_panels(struct image *image, signed int *data, int data_width) +static int unpack_panels(struct image *image, signed int *data, int data_width, + int data_height) { int pi; @@ -471,6 +472,14 @@ static int unpack_panels(struct image *image, signed int *data, int data_width) "with CBF files\n"); } + if ( (p->orig_min_fs + p->w > data_width) + || (p->orig_min_ss + p->h > data_height) ) + { + ERROR("Panel %s is outside range of data in CBF file\n", + p->name); + return 1; + } + for ( ss=0; ss<p->h; ss++ ) { for ( fs=0; fs<p->w; fs++ ) { @@ -574,6 +583,11 @@ static int read_cbf(struct imagefile *f, struct image *image) const char *byteorder; signed int *data; + if ( image->det == NULL ) { + ERROR("read_cbf() needs a geometry\n"); + return 1; + } + if ( cbf_make_handle(&cbfh) ) { ERROR("Failed to allocate CBF handle\n"); return 1; @@ -656,7 +670,7 @@ static int read_cbf(struct imagefile *f, struct image *image) return 1; } - unpack_panels(image, data, dimfast); + unpack_panels(image, data, dimfast, dimmid); free(data); if ( image->beam != NULL ) { |