diff options
author | Eric Jackson <ericj@cvs.openbsd.org> | 2001-01-03 16:04:41 +0000 |
---|---|---|
committer | Eric Jackson <ericj@cvs.openbsd.org> | 2001-01-03 16:04:41 +0000 |
commit | 994cdb8d3b777662b6dba5a039c1d9a19e82a1cb (patch) | |
tree | c62445a704a87c84eeb6224e13a2089a0cfcc923 /usr.sbin/dhcp/dhclient | |
parent | 1fc55dfbde4a8de5d2139db13d4cef0f0689c4d3 (diff) |
-Wall cleanup.
roll a function for writing out pidfile's instead of rolling it for each
program.
be careful with a few more buffers
Diffstat (limited to 'usr.sbin/dhcp/dhclient')
-rw-r--r-- | usr.sbin/dhcp/dhclient/clparse.c | 7 | ||||
-rw-r--r-- | usr.sbin/dhcp/dhclient/dhclient.c | 30 |
2 files changed, 7 insertions, 30 deletions
diff --git a/usr.sbin/dhcp/dhclient/clparse.c b/usr.sbin/dhcp/dhclient/clparse.c index b3406ae01cf..9f89be5f199 100644 --- a/usr.sbin/dhcp/dhclient/clparse.c +++ b/usr.sbin/dhcp/dhclient/clparse.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: clparse.c,v 1.5 1999/12/04 00:15:08 angelos Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: clparse.c,v 1.6 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -751,10 +751,9 @@ struct option *parse_option_decl (cfile, options) skip_to_semi (cfile); return (struct option *)0; } - vendor = malloc (strlen (val) + 1); - if (!vendor) + if ((vendor = (char *)malloc (strlen (val))) == NULL) error ("no memory for vendor information."); - strcpy (vendor, val); + strlcpy(vendor, val, strlen(vendor)); token = peek_token (&val, cfile); if (token == DOT) { /* Go ahead and take the DOT token... */ diff --git a/usr.sbin/dhcp/dhclient/dhclient.c b/usr.sbin/dhcp/dhclient/dhclient.c index 33cd3493066..6ff387acd26 100644 --- a/usr.sbin/dhcp/dhclient/dhclient.c +++ b/usr.sbin/dhcp/dhclient/dhclient.c @@ -56,7 +56,7 @@ #ifndef lint static char copyright[] = -"$Id: dhclient.c,v 1.12 2000/12/29 14:36:04 angelos Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.13 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -82,7 +82,6 @@ struct tree_cache *global_options [256]; char *path_dhclient_conf = _PATH_DHCLIENT_CONF; char *path_dhclient_db = _PATH_DHCLIENT_DB; -char *path_dhclient_pid = _PATH_DHCLIENT_PID; int interfaces_requested = 0; @@ -243,7 +242,7 @@ static void usage () void cleanup () { /* Make sure the pidfile is gone. */ - (void) unlink (path_dhclient_pid); + (void) unlink (_PATH_DHCLIENT_PID); } /* Individual States: @@ -2073,7 +2072,7 @@ void go_daemon () /* Don't become a daemon if the user requested otherwise. */ if (no_daemon) { - write_client_pid_file (); + write_pidfile(_PATH_DHCLIENT_PID, getpid()); return; } @@ -2093,28 +2092,7 @@ void go_daemon () /* Become session leader and get pid... */ pid = setsid (); - write_client_pid_file (); -} - -void write_client_pid_file () -{ - FILE *pf; - int pfdesc; - - pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644); - - if (pfdesc < 0) { - warn ("Can't create %s: %m", path_dhclient_pid); - return; - } - - pf = fdopen (pfdesc, "w"); - if (!pf) - warn ("Can't fdopen %s: %m", path_dhclient_pid); - else { - fprintf (pf, "%ld\n", (long)getpid ()); - fclose (pf); - } + write_pidfile(_PATH_DHCLIENT_PID, getpid()); } int check_option (struct client_lease *l, int option) { |