summaryrefslogtreecommitdiff
path: root/usr.sbin/pw
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-09-01 15:15:09 +0000
committerMark Johnston <markj@FreeBSD.org>2020-09-01 15:15:09 +0000
commit645c2851e21b266ad21b9644a75dbc056606e1b9 (patch)
treeae1813bd66790974ec6435c9ffeac082ac2a9b7e /usr.sbin/pw
parent7a82cf511d6d3187ef22840f5836e74a0accad0d (diff)
Notes
Diffstat (limited to 'usr.sbin/pw')
-rw-r--r--usr.sbin/pw/pw_user.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index cb95d45068658..2eec317b5e5b5 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -712,24 +712,24 @@ rmopie(char const * name)
{
char tmp[1014];
FILE *fp;
- int fd;
size_t len;
- off_t atofs = 0;
-
+ long atofs;
+ int fd;
+
if ((fd = openat(conf.rootfd, "etc/opiekeys", O_RDWR)) == -1)
return;
fp = fdopen(fd, "r+");
len = strlen(name);
- while (fgets(tmp, sizeof(tmp), fp) != NULL) {
+ for (atofs = 0; fgets(tmp, sizeof(tmp), fp) != NULL && atofs >= 0;
+ atofs = ftell(fp)) {
if (strncmp(name, tmp, len) == 0 && tmp[len]==' ') {
/* Comment username out */
if (fseek(fp, atofs, SEEK_SET) == 0)
fwrite("#", 1, 1, fp);
break;
}
- atofs = ftell(fp);
}
/*
* If we got an error of any sort, don't update!