d-e-s-o / nitrocli

A command line tool for interacting with Nitrokey devices.
30 stars 10 forks source link

Improve error messages for overlong input data #170

Closed robinkrahl closed 3 years ago

robinkrahl commented 3 years ago

Previously, we didn’t check the length of the input data in the otp set, pws add and pws update commands. While libnitrokey does check the input and return an error if a string is too long, it cannot inform us which of the input strings is the problematic one.

With this patch, we manually validate the input string lengths for these commands to improve the error messages, clearly stating which strings are problematic, how long they are and how long they can be.

Fixes #161.

d-e-s-o commented 3 years ago

Great work! Thanks Robin! Should we have an issue open and a TODO referencing it to not forget about the move away from hardcoding these maximum lengths in nitrocli?

robinkrahl commented 3 years ago

Thanks! We have the libnitrokey issue and PR. Once a new libnitrokey version is released, I’ll update nitrokey-sys. And for every nitrokey-sys update, I check which changes are relevant for nitrocli. So having another issue or TODO is not necessary for me, but feel free to add it if you want to.

d-e-s-o commented 3 years ago

Sounds good. That should be good enough then. Merged!