Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src/usr.sbin/rpc.statd Pull up following revision(s) (request...
details: https://anonhg.NetBSD.org/src/rev/ad38fc008ca7
branches: netbsd-3
changeset: 577569:ad38fc008ca7
user: riz <riz%NetBSD.org@localhost>
date: Sun Nov 27 22:55:29 2005 +0000
description:
Pull up following revision(s) (requested by bouyer in ticket #1007):
usr.sbin/rpc.statd/statd.c: revision 1.25
We can't call db->put() with key or data pointing back to db(3)'s memory
space, or the database will be corrupted (noticed when the database is
updated in reset_host()). Change change_host() to copy hostname and HostInfo
to local storage before calling db->put().
Change notify_one() to use change_host() instead of calling db->put()
directly.
diffstat:
usr.sbin/rpc.statd/statd.c | 31 +++++++++++++------------------
1 files changed, 13 insertions(+), 18 deletions(-)
diffs (77 lines):
diff -r b8b62f87fc76 -r ad38fc008ca7 usr.sbin/rpc.statd/statd.c
--- a/usr.sbin/rpc.statd/statd.c Sun Nov 27 22:49:30 2005 +0000
+++ b/usr.sbin/rpc.statd/statd.c Sun Nov 27 22:55:29 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: statd.c,v 1.23.6.1 2005/10/22 03:41:12 riz Exp $ */
+/* $NetBSD: statd.c,v 1.23.6.2 2005/11/27 22:55:29 riz Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: statd.c,v 1.23.6.1 2005/10/22 03:41:12 riz Exp $");
+__RCSID("$NetBSD: statd.c,v 1.23.6.2 2005/11/27 22:55:29 riz Exp $");
#endif
/* main() function for status monitor daemon. Some of the code in this */
@@ -241,12 +241,17 @@
*
*/
void
-change_host(hostname, hp)
- char *hostname;
+change_host(hostnamep, hp)
+ char *hostnamep;
HostInfo *hp;
{
DBT key, data;
char *ptr;
+ char hostname[MAXHOSTNAMELEN + 1];
+ HostInfo h;
+
+ strncpy(hostname, hostnamep, MAXHOSTNAMELEN + 1);
+ h = *hp;
for (ptr = hostname; *ptr; ptr++)
if (isupper((unsigned char) *ptr))
@@ -254,8 +259,8 @@
key.data = hostname;
key.size = ptr - hostname + 1;
- data.data = hp;
- data.size = sizeof(*hp);
+ data.data = &h;
+ data.size = sizeof(h);
switch ((*db->put)(db, &key, &data, 0)) {
case -1:
@@ -458,7 +463,6 @@
{
time_t now = *(time_t *) ptr;
char *name = key->data;
- DBT data;
int error;
if (hi->notifyReqd == 0 || hi->notifyReqd > now)
@@ -495,17 +499,8 @@
else
hi->notifyReqd += 60 * 60;
}
- data.data = hi;
- data.size = sizeof(*hi);
- switch ((*db->put)(db, key, &data, 0)) {
- case -1:
- syslog(LOG_ERR, "Error storing %s (%m)", name);
- case 0:
- return error;
-
- default:
- abort();
- }
+ change_host(name, hi);
+ return error;
}
/* init_file -------------------------------------------------------------- */
Home |
Main Index |
Thread Index |
Old Index