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

%s in data_object name causes segfault #267

Closed sb10 closed 1 year ago

sb10 commented 1 year ago

Test with a (non-existent) path "s.txt" works as expected:

jq -n '{collection: "/zone/", data_object: "s.txt"}' | baton-list
2023-03-07T14:35:42Z ERROR Path '/zone/s.txt' does not exist (or lacks access permission)
{"collection": "/zone/", "data_object": "s.txt", "error": {"message": "Path '/zone/s.txt' does not exist (or lacks access permission)", "code": -310000}}
2023-03-07T14:35:42Z WARN Processed 1 items with 1 errors

Test with a (non-existent) path "%s.txt" segfaults:

jq -n '{collection: "/zone/", data_object: "%s.txt"}' | baton-list
2023-03-07T14:35:47Z ERROR Segmentation fault

This is when using /software/sciops/pkgg/baton/4.0.0/bin/baton-list

kjsanger commented 1 year ago

This is caused by accidental omission of a printf format string when handling some errors. In that event, the argument to the format is used as the format string and as it contains an unescaped %, looks for a further argument, which is NULL.

kjsanger commented 1 year ago

Fixed by #269