Browse Source

Richard June <rjune@bravegnuworld.com> noticed that pututline
was only writing the first sizeof-a-pointer bytes to the utmp
file. oops.
-Erik

Eric Andersen 22 years ago
parent
commit
61b4383511
1 changed files with 4 additions and 6 deletions
  1. 4 6
      libc/misc/utmp/utent.c

+ 4 - 6
libc/misc/utmp/utent.c

@@ -108,17 +108,15 @@ struct utmp *pututline (const struct utmp *utmp_entry)
 
 	/* Ignore the return value.  That way, if they've already positioned
 	   the file pointer where they want it, everything will work out. */
-	(void) lseek(ut_fd, (off_t) - sizeof(utmp_entry), SEEK_CUR);
+	(void) lseek(ut_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
 
 	if ((ut = getutid(utmp_entry)) != NULL) {
-		lseek(ut_fd, (off_t) - sizeof(utmp_entry), SEEK_CUR);
-		if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
-			!= sizeof(utmp_entry))
+		lseek(ut_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+		if (write(ut_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
 			return NULL;
 	} else {
 		lseek(ut_fd, (off_t) 0, SEEK_END);
-		if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
-			!= sizeof(utmp_entry))
+		if (write(ut_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
 			return NULL;
 	}