tools/hash: protect against invalid arg count

This commit is contained in:
Danny Robson 2016-06-17 14:58:12 +10:00
parent 850fa0470f
commit e62af110b6

View File

@ -99,17 +99,29 @@ enum {
ARG_CMD,
ARG_HASH,
ARG_INPUT,
NUM_ARGS
};
int
main (int argc, char **argv) {
if (argc < ARG_INPUT) {
//-----------------------------------------------------------------------------
void
print_usage (int argc, char **argv)
{
(void)argc;
std::cerr << argv[ARG_CMD] << " [";
for (auto name: NAMES)
std::cerr << name << "|";
std::cerr << "] <input>\n";
}
//-----------------------------------------------------------------------------
int
main (int argc, char **argv) {
if (argc != NUM_ARGS) {
print_usage (argc, argv);
return EXIT_FAILURE;
}