wtsi-npg / baton

iRODS client programs and API
http://wtsi-npg.github.io/baton
GNU General Public License v2.0
19 stars 19 forks source link

Set `num_read` to zero in `read_chunk` error block. #253

Closed mksanger closed 2 years ago

mksanger commented 3 years ago

Negative values of iRODS errors were causing overflow when returned as size_t, which caused slurp_data_obj to attempt to access a very large chunk of memory, resulting in a segmentation fault.

kjsanger commented 2 years ago

It occurred to me that if the user doesn't have permission to read the data object, then rcDataObjOpen should fail before we even get as far as reading. I wrote a regression test for this and was having trouble reproducing the error on an iRODS 4.2.10 server, so I went back to 4.2.7 and it segfaults, as expected.

Therefore there's also an iRODS bug here that was fixed between 4.2.7 and 4.2.10.

kjsanger commented 2 years ago

I've created a pull request to your pull request because we should really have a regression test for this. The behaviour is complicated by what appears to be an iRODS bug, so I've had a go at unpicking what's going on,