commit 332a3764ecbe5c65ad224bbf6c2e7ac6b1a9bbb5
parent 62cd36ec7e2e916d357ed07302094c1d7a69d1e9
Author: kqueue <kqueue@cocaine.ninja>
Date: Sun, 29 Oct 2023 15:13:16 -0400
added help message and fixed potential buffer overflow
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/passman.c b/passman.c
@@ -243,7 +243,7 @@ void walk(char *path, int len)
} else if (strcmp(de->d_name, "passman-hash") == 0) {
/* do nothing */
} else if (de->d_type == DT_DIR) {
- int length = strlen(path) + strlen(de->d_name);
+ int length = strlen(path) + strlen(de->d_name) + 3;
char dir[length];
sprintf(dir, "%s/%s", path, de->d_name);
walk(dir, len);
@@ -298,6 +298,10 @@ void show(char *path)
int main(int argc, char *argv[])
{
+ if(argv[1] == NULL || strcmp(argv[1], "help") == 0 ){
+ printf("Usage:\n\tpassman help\tdisplays help message\n\tpassman generate [name] [length]\tgenerates a password and securely stores it\n\tpassman show [name]\tprints the unencrypted value of a stored password\n\tpassman add\tprompts for a password and securely stores it\n\tpassman list\tlists the passwords that are stored\n");
+ return 0;
+ }
if (strcmp(argv[1], "init") == 0) {
init();
return 0;
@@ -328,7 +332,7 @@ int main(int argc, char *argv[])
sprintf(path, "%s/.passman-store/", getenv("HOME"));
walk(path, strlen(path)+1);
} else {
- puts("wtf");
+ puts("command not found");
return 0;
}
}