summaryrefslogtreecommitdiffstats
path: root/pw/pw_user.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-05-09 22:48:48 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-05-09 22:48:48 +0000
commitfdadb44760e882a368c272d308398b391f2fc286 (patch)
treef0796e0e6c4424eca2f862ce9447d8b07f765d16 /pw/pw_user.c
parent020fd2ca7fd6eb436c750af2f59d5d60c9b9d221 (diff)
downloadpw-darwin-fdadb44760e882a368c272d308398b391f2fc286.tar.gz
pw-darwin-fdadb44760e882a368c272d308398b391f2fc286.tar.zst
pw-darwin-fdadb44760e882a368c272d308398b391f2fc286.zip
Replace sprintf(3) with snprintf(3)
Diffstat (limited to 'pw/pw_user.c')
-rw-r--r--pw/pw_user.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index d7aed71..b058aab 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -397,7 +397,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
snprintf(file, sizeof(file), "/var/cron/tabs/%s", pwd->pw_name);
if (access(file, F_OK) == 0) {
- sprintf(file, "crontab -u %s -r", pwd->pw_name);
+ snprintf(file, sizeof(file), "crontab -u %s -r", pwd->pw_name);
system(file);
}
}
@@ -405,7 +405,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* Save these for later, since contents of pwd may be
* invalidated by deletion
*/
- sprintf(file, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(file, sizeof(file), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
strlcpy(home, pwd->pw_dir, sizeof(home));
gr = GETGRGID(pwd->pw_gid);
if (gr != NULL)
@@ -811,7 +811,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if (mode == M_ADD) {
if (!PWALTDIR()) {
- sprintf(line, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(line, sizeof(line), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
close(open(line, O_RDWR | O_CREAT, 0600)); /* Preserve contents &
* mtime */
chown(line, pwd->pw_uid, pwd->pw_gid);
@@ -955,7 +955,7 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer
* function will happily handle that case for us and exit.
*/
if (GETGRGID(prefer) == NULL) {
- sprintf(tmp, "%lu", (unsigned long) prefer);
+ snprintf(tmp, sizeof(tmp), "%u", prefer);
addarg(&grpargs, 'g', tmp);
}
if (getarg(args, 'N'))
@@ -1048,12 +1048,12 @@ shell_path(char const * path, char *shells[], char *sh)
static char shellpath[256];
if (sh != NULL) {
- sprintf(shellpath, "%s/%s", p, sh);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, sh);
if (access(shellpath, X_OK) == 0)
return shellpath;
} else
for (i = 0; i < _UC_MAXSHELLS && shells[i] != NULL; i++) {
- sprintf(shellpath, "%s/%s", p, shells[i]);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, shells[i]);
if (access(shellpath, X_OK) == 0)
return shellpath;
}
@@ -1303,7 +1303,7 @@ rmat(uid_t uid)
st.st_uid == uid) {
char tmp[MAXPATHLEN];
- sprintf(tmp, "/usr/bin/atrm %s", e->d_name);
+ snprintf(tmp, sizeof(tmp), "/usr/bin/atrm %s", e->d_name);
system(tmp);
}
}