From cf7147a90fa84d3af699ed369355e470ec3a7536 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Wed, 22 May 2024 10:35:22 +0900 Subject: [PATCH] segfault --- main.c | 6 +++++- src/showpass.c | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5d61ba6..e198893 100644 --- a/main.c +++ b/main.c @@ -78,7 +78,11 @@ int main(int argc, char *argv[]) { if (argc == 3) { if (strcmp(argv[1], "-i") == 0) initpass(argv[2]); - else if (strcmp(argv[1], "-s") == 0) printf("%s\n", showpass(argv[2])); + else if (strcmp(argv[1], "-s") == 0) { + const char *pass = showpass(argv[2]); + if (pass == NULL) return -1; + printf("%s\n", pass); + } else if (strcmp(argv[1], "-y") == 0) yankpass(argv[2]); else if (strcmp(argv[1], "-a") == 0) addpass(argv[2]); else if (strcmp(argv[1], "-d") == 0) delpass(argv[2], 0); diff --git a/src/showpass.c b/src/showpass.c index 9d422d0..3347004 100644 --- a/src/showpass.c +++ b/src/showpass.c @@ -68,10 +68,8 @@ const char *showpass(char *file) { if (gpgfile == NULL) { if (strncmp(lang, "en", 2) == 0) { perror("Failed to opening file"); - fprintf(stderr, "Failing path: %s\n", gpgpath); } else { perror("ファイルを開くに失敗"); - fprintf(stderr, "失敗したパス: %s\n", gpgpath); } free(gpgpath); return NULL; -- 2.43.0