[Pkg-shadow-commits] r2186 - in upstream/trunk: . libmisc
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Sun Jun 15 19:15:16 UTC 2008
Author: nekral-guest
Date: 2008-06-15 19:15:15 +0000 (Sun, 15 Jun 2008)
New Revision: 2186
Modified:
upstream/trunk/ChangeLog
upstream/trunk/libmisc/log.c
Log:
* libmisc/log.c: Check return values. If lseek() failed, avoid
reading or writing at an unspecified location. Log to syslog in
case of failure.
* libmisc/log.c: Use the right casts.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-15 18:33:52 UTC (rev 2185)
+++ upstream/trunk/ChangeLog 2008-06-15 19:15:15 UTC (rev 2186)
@@ -1,5 +1,12 @@
2008-06-15 Nicolas François <nicolas.francois at centraliens.net>
+ * libmisc/log.c: Check return values. If lseek() failed, avoid
+ reading or writing at an unspecified location. Log to syslog in
+ case of failure.
+ * libmisc/log.c: Use the right casts.
+
+2008-06-15 Nicolas François <nicolas.francois at centraliens.net>
+
* libmisc/find_new_ids.c, libmisc/find_new_gid.c,
libmisc/find_new_uid.c, libmisc/Makefile.am, lib/prototypes.h:
Split find_new_ids.c into find_new_gid.c and find_new_uid.c to
Modified: upstream/trunk/libmisc/log.c
===================================================================
--- upstream/trunk/libmisc/log.c 2008-06-15 18:33:52 UTC (rev 2185)
+++ upstream/trunk/libmisc/log.c 2008-06-15 19:15:15 UTC (rev 2186)
@@ -72,7 +72,7 @@
* for this UID. Negative UID's will create problems, but ...
*/
- offset = (unsigned long) pw->pw_uid * sizeof newlog;
+ offset = (off_t) pw->pw_uid * sizeof newlog;
if (lseek (fd, offset, SEEK_SET) != offset) {
close (fd);
@@ -85,7 +85,7 @@
* the way we read the old one in.
*/
- if (read (fd, (char *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog) {
+ if (read (fd, (void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog) {
memzero (&newlog, sizeof newlog);
}
if (NULL != ll) {
@@ -99,9 +99,13 @@
#if HAVE_LL_HOST
strncpy (newlog.ll_host, host, sizeof newlog.ll_host);
#endif
- if (lseek (fd, offset, SEEK_SET) == offset) {
- write (fd, (char *) &newlog, sizeof newlog);
+ if ( (lseek (fd, offset, SEEK_SET) != offset)
+ || (write (fd, (const void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog)
+ || (close (fd) != 0)) {
+ SYSLOG ((LOG_WARN,
+ "Can't write lastlog entry for UID %lu in %s.",
+ (unsigned long) pw->pw_uid, LASTLOG_FILE));
+ (void) close (fd);
}
- close (fd);
}
More information about the Pkg-shadow-commits
mailing list