aboutsummaryrefslogtreecommitdiff
path: root/src/libnpass
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-04-10 06:52:59 +0530
committersinanmohd <sinan@sinanmohd.com>2024-04-10 17:38:00 +0530
commit9293ed4628222ca4d618e2147c4db94e22106ae4 (patch)
tree5f3a185aba13c3e279b55b938bd45aff01b33f4c /src/libnpass
parent630ad61bcc9a18b89b3399b20be8919611bbcfb0 (diff)
src: avoid unnecessary sizeof() - 1
Diffstat (limited to 'src/libnpass')
-rw-r--r--src/libnpass/libnpass.c12
-rw-r--r--src/libnpass/util.c2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c
index b9ce58e..a918e77 100644
--- a/src/libnpass/libnpass.c
+++ b/src/libnpass/libnpass.c
@@ -46,14 +46,14 @@ int set_pass_dir(void) {
env = getenv("XDG_DATA_HOME");
if (env) {
- snprintf(pass_dir, sizeof(pass_dir) - 1, "%s/%s", env,
+ snprintf(pass_dir, sizeof(pass_dir), "%s/%s", env,
DEF_PASS_DIR);
return 0;
}
env = getenv("HOME");
if (env) {
- snprintf(pass_dir, sizeof(pass_dir) - 1, "%s/%s/%s", env,
+ snprintf(pass_dir, sizeof(pass_dir), "%s/%s/%s", env,
".local/share", DEF_PASS_DIR);
return 0;
}
@@ -104,7 +104,7 @@ pass_store_t pass_store_type(const char *spath) {
if (r)
err_ret(PASS_STORE_INV, "PASSWORD_STORE_DIR not set");
- r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s",
+ r = snprintf(abs_path, sizeof(abs_path), "%s/%s",
pass_dir, (spath) ? spath : "");
if (r >= (int) sizeof(abs_path))
err_ret(PASS_STORE_INV, "path exceeded PATH_MAX");
@@ -112,7 +112,7 @@ pass_store_t pass_store_type(const char *spath) {
if (!r && (sbuf.st_mode & S_IFMT) == S_IFDIR)
return PASS_STORE_DIR;
- r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s.gpg",
+ r = snprintf(abs_path, sizeof(abs_path), "%s/%s.gpg",
pass_dir, spath);
if (r >= (int) sizeof(abs_path))
err_ret(PASS_STORE_INV, "path exceeded PATH_MAX");
@@ -139,7 +139,7 @@ DIR *openstore(const char *spath) {
err_ret(NULL, "%s is not a passwordstore directory", spath);
if (spath) {
- r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s",
+ r = snprintf(abs_path, sizeof(abs_path), "%s/%s",
pass_dir, spath);
if (r >= (int) sizeof(abs_path))
err_ret(NULL, "path exceeded PATH_MAX");
@@ -173,7 +173,7 @@ int readstore(DIR *dirp, struct store *s) {
return EOF;
}
- strncpy(s->name , dir->d_name, sizeof(s->name));
+ strncpy(s->name , dir->d_name, sizeof(s->name) - 1);
switch (dir->d_type) {
case DT_DIR:
s->type = PASS_STORE_DIR;
diff --git a/src/libnpass/util.c b/src/libnpass/util.c
index 11cf264..e2bbbff 100644
--- a/src/libnpass/util.c
+++ b/src/libnpass/util.c
@@ -16,7 +16,7 @@ int r_mkdir(const char *path, mode_t mode)
char *p;
char tmp[NAME_MAX + 1];
- strncpy(tmp, path, sizeof(tmp) - 1);
+ strncpy(tmp, path, sizeof(tmp));
len = strlen(tmp);
if(tmp[len - 1] == '/')
tmp[len - 1] = '\0';