From 64a8f1930eeedc3d897172f65d4c582482831122 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 7 Sep 2021 16:44:08 +0200 Subject: [PATCH] history: emit a warning when file cannot be made private [coverity] --- src/history.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/history.c b/src/history.c index 91677574..0f80fbae 100644 --- a/src/history.c +++ b/src/history.c @@ -367,7 +367,8 @@ void save_history(void) } /* Don't allow others to read or write the history file. */ - chmod(histname, S_IRUSR | S_IWUSR); + if (chmod(histname, S_IRUSR | S_IWUSR) < 0) + jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno)); if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) || !write_list(executetop, histfile)) @@ -465,7 +466,8 @@ void save_poshistory(void) } /* Don't allow others to read or write the history file. */ - chmod(poshistname, S_IRUSR | S_IWUSR); + if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0) + jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno)); for (posptr = position_history; posptr != NULL; posptr = posptr->next) { char *path_and_place;