* NET-3 Networking Distribution for the LINUX operating
* system.
*
- * Version: $Id: arp.c,v 1.9 1998/11/15 20:07:31 freitag Exp $
+ * Version: $Id: arp.c,v 1.10 1998/11/17 15:16:09 freitag Exp $
*
* Maintainer: Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
*
#include "version.h"
#include "config.h"
#include "intl.h"
+#include "util.h"
#define DFLT_AF "inet"
#define DFLT_HW "ether"
fprintf(stderr, _("arp: need host name\n"));
return (-1);
}
- host[(sizeof host) - 1] = 0;
- strncpy(host, *args, (sizeof host) - 1);
+ safe_strncpy(host, *args, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
return (-1);
if (!strcmp(*args, "dev")) {
if (*++args == NULL)
usage();
- strncpy(device, *args, sizeof(device) - 1);
- device[sizeof(device) - 1] = '\0';
+ safe_strncpy(device, *args, sizeof(device));
args++;
continue;
}
fprintf(stderr, _("arp: need host name\n"));
return (-1);
}
- host[(sizeof host) - 1] = 0;
- strncpy(host, *args++, (sizeof host) - 1);
+ safe_strncpy(host, *args++, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
return (-1);
if (!strcmp(*args, "dev")) {
if (*++args == NULL)
usage();
- strncpy(device, *args, sizeof(device) - 1);
- device[sizeof(device) - 1] = '\0';
+ safe_strncpy(device, *args, sizeof(device));
args++;
continue;
}
if (name != NULL) {
/* Resolve the host name. */
- host[(sizeof host) - 1] = 0;
- strncpy(host, name, (sizeof host) - 1);
+ safe_strncpy(host, name, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
return (-1);
hw_set = 1;
break;
case 'i':
- strncpy(device, optarg, sizeof(device) - 1);
- device[sizeof(device) - 1] = '\0';
+ safe_strncpy(device, optarg, sizeof(device));
break;
case 'V':
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
- * Version: $Id: ifconfig.c,v 1.18 1998/11/15 20:07:42 freitag Exp $
+ * Version: $Id: ifconfig.c,v 1.19 1998/11/17 15:16:14 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
/* If needed, display the interface statistics. */
if (ptr->statistics_valid) {
- /* XXX: statistics are currently only printed for the original address,
- * not for the aliases, although strictly speaking they're shared
+ /* XXX: statistics are currently only printed for the primary address,
+ * not for the aliases, although strictly speaking they're shared
* by all addresses.
*/
printf(" ");
printf(_("txqueuelen:%d "), ptr->tx_queue_len);
printf("\n");
}
+
if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
ptr->map.base_addr)) {
printf(" ");
printf("\n");
}
+static int do_if_fetch(struct interface *ife)
+{
+ if (if_fetch(ife) < 0) {
+ char *errmsg;
+ if (errno == ENODEV) {
+ /* Give better error message for this case. */
+ errmsg = _("Device not found");
+ } else {
+ errmsg = strerror(errno);
+ }
+ fprintf(stderr, _("%s: error fetching interface information: %s\n"),
+ ife->name, errmsg);
+ return -1;
+ }
+ return 0;
+}
+
static int do_if_print(struct interface *ife, void *cookie)
{
int *opt_a = (int *) cookie;
+ int res;
- if (if_fetch(ife->name, ife) < 0) {
- fprintf(stderr, _("%s: error fetching interface information: %s\n\n"),
- ife->name, strerror(errno));
- return -1;
+ res = do_if_fetch(ife);
+ if (res >= 0) {
+ if ((ife->flags & IFF_UP) || *opt_a)
+ ife_print(ife);
}
- if (!(ife->flags & IFF_UP) && !(*opt_a))
- return 0;
- ife_print(ife);
- return 0;
+ return res;
}
-static void if_print(char *ifname)
+static int if_print(char *ifname)
{
- struct interface *ife;
+ int res;
if (!ifname) {
- for_all_interfaces(do_if_print, &opt_a);
+ res = for_all_interfaces(do_if_print, &opt_a);
} else {
+ struct interface *ife;
+
ife = lookup_interface(ifname);
- if (!ife)
- fprintf(stderr, _("%s: interface not found.\n"), ifname);
- else if (if_fetch(ifname, ife) < 0)
- fprintf(stderr, _("%s: error fetching interface information: %s"),
- ifname, strerror(errno));
- else
+ res = do_if_fetch(ife);
+ if (res >= 0)
ife_print(ife);
}
+ return res;
}
/* Do we have to show the current setup? */
if (argc == 0) {
- if_print((char *) NULL);
+ int err = if_print((char *) NULL);
(void) close(skfd);
- exit(0);
+ exit(err < 0);
}
/* No. Fetch the interface name. */
spp = argv;
- strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
+ safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
if (*spp == (char *) NULL) {
- if_print(ifr.ifr_name);
+ int err = if_print(ifr.ifr_name);
(void) close(skfd);
- exit(0);
+ exit(err < 0);
}
/* The next argument is either an address family name, or an option. */
if ((ap = get_aftype(*spp)) == NULL)
}
if (!strcmp(*spp, "broadcast")) {
if (*++spp != NULL) {
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
goterr = 1;
if (!strcmp(*spp, "dstaddr")) {
if (*++spp == NULL)
usage();
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
goterr = 1;
if (!strcmp(*spp, "netmask")) {
if (*++spp == NULL || didnetmask)
usage();
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa) < 0) {
ap->herror(host);
goterr = 1;
if (!strcmp(*spp, "pointopoint")) {
if (*(spp + 1) != NULL) {
spp++;
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (ap->input(0, host, &sa)) {
ap->herror(host);
goterr = 1;
usage();
if (*++spp == NULL)
usage();
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (hw->input(host, &sa) < 0) {
fprintf(stderr, _("%s: invalid %s address.\n"), host, hw->name);
goterr = 1;
} else {
prefix_len = 0;
}
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host, (struct sockaddr *) &sa6) < 0) {
inet6_aftype.herror(host);
goterr = 1;
} else {
prefix_len = 0;
}
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host, (struct sockaddr *) &sa6) < 0) {
inet6_aftype.herror(host);
goterr = 1;
} else {
prefix_len = 0;
}
- host[(sizeof host) - 1] = 0;
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
if (inet6_aftype.input(1, host, (struct sockaddr *) &sa6) < 0) {
inet6_aftype.herror(host);
goterr = 1;
#endif
/* If the next argument is a valid hostname, assume OK. */
- host[(sizeof host) - 1] = '\0';
- strncpy(host, *spp, (sizeof host) - 1);
+ safe_strncpy(host, *spp, (sizeof host));
/* FIXME: sa is too small for INET6 addresses, inet6 should use that too,
broadcast is unexpected */
10/1998 partly rewriten by Andi Kleen to support an interface list.
I don't claim that the list operations are efficient @).
- $Id: interface.c,v 1.10 1998/11/15 20:07:52 freitag Exp $
+ $Id: interface.c,v 1.11 1998/11/17 15:16:20 freitag Exp $
*/
#include "config.h"
struct interface *lookup_interface(char *name)
{
- struct interface *ife;
- if (!int_list && (if_readlist()) < 0)
- return NULL;
- for (ife = int_list; ife; ife = ife->next) {
- if (!strcmp(ife->name, name))
- break;
+ struct interface *ife = NULL;
+
+ if (int_list || if_readlist() >= 0) {
+ for (ife = int_list; ife; ife = ife->next) {
+ if (!strcmp(ife->name, name))
+ break;
+ }
+ }
+
+ if (!ife) {
+ new(ife);
+ safe_strncpy(ife->name, name, IFNAMSIZ-1);
+ add_interface(ife);
}
+
return ife;
}
int n, err = -1;
int skfd;
- /* SIOCGIFCONF seems to only work properly on AF_INET sockets
- currently */
+ /* SIOCGIFCONF currently seems to only work properly on AF_INET sockets
+ (as of 2.1.128) */
skfd = get_socket_for_af(AF_INET);
if (skfd < 0) {
fprintf(stderr, _("warning: no inet socket available: %s\n"),
strerror(errno));
return -1;
}
+
ifc.ifc_buf = NULL;
for (;;) {
ifc.ifc_len = sizeof(struct ifreq) * numreqs;
break;
}
- for (ifr = ifc.ifc_req, n = 0; n < ifc.ifc_len;
- n += sizeof(struct ifreq), ifr++) {
- struct interface *ife;
-
- ife = lookup_interface(ifr->ifr_name);
- if (ife)
- continue;
-
- new(ife);
- strcpy(ife->name, ifr->ifr_name);
- add_interface(ife);
+ ifr = ifc.ifc_req;
+ for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq)) {
+ lookup_interface(ifr->ifr_name);
+ ifr++;
}
err = 0;
- out:
+out:
free(ifc.ifc_buf);
return err;
}
#endif
/* Fetch the interface configuration from the kernel. */
-int if_fetch(char *ifname, struct interface *ife)
+int if_fetch(struct interface *ife)
{
struct ifreq ifr;
int fd;
+ char *ifname = ife->name;
strcpy(ifr.ifr_name, ifname);
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
int outfill; /* outfill value for SLIP */
};
-extern int if_fetch(char *ifname, struct interface *ife);
+extern int if_fetch(struct interface *ife);
extern int for_all_interfaces(int (*)(struct interface *, void *), void *);
extern struct interface *lookup_interface(char *name);
* lib/af.c This file contains the top-level part of the protocol
* support functions module for the NET-2 base distribution.
*
- * Version: $Id: af.c,v 1.6 1998/11/15 20:08:59 freitag Exp $
+ * Version: $Id: af.c,v 1.7 1998/11/17 15:16:26 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
char *tmp1, *tmp2;
char buf[256];
- strncpy(buf, arg, sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
+ safe_strncpy(buf, arg, sizeof(buf));
tmp1 = buf;
* lib/arcnet.c This file contains an implementation of the "ARCnet"
* support functions for the NET-2 base distribution.
*
- * Version: $Id: arcnet.c,v 1.3 1998/11/15 20:09:06 freitag Exp $
+ * Version: $Id: arcnet.c,v 1.4 1998/11/17 15:16:29 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (pr_arcnet(sap->sa_data));
}
/*
* lib/ash.c This file contains an implementation of the Ash
* support functions for the NET-2 base distribution.
- * $Id: ash.c,v 1.6 1998/11/15 20:09:16 freitag Exp $
+ * $Id: ash.c,v 1.7 1998/11/17 15:16:31 freitag Exp $
*/
#include "config.h"
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, "[NONE SET]", 64);
+ return safe_strncpy(buf, "[NONE SET]", 64);
return pr_ash(sap->sa_data);
}
* lib/ax25.c This file contains an implementation of the "AX.25"
* support functions.
*
- * Version: $Id: ax25.c,v 1.6 1998/11/15 20:09:19 freitag Exp $
+ * Version: $Id: ax25.c,v 1.7 1998/11/17 15:16:32 freitag Exp $
*
* NOTE: I will redo this module as soon as I got the libax25.a
* library sorted out. This library contains some useful
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (AX25_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
}
if (islower(c))
c = toupper(c);
if (!(isupper(c) || isdigit(c))) {
- strncpy(AX25_errmsg, _("Invalid callsign"), sizeof(AX25_errmsg)-2);
- AX25_errmsg[sizeof(AX25_errmsg)-1]=0;
+ safe_strncpy(AX25_errmsg, _("Invalid callsign"), sizeof(AX25_errmsg));
#ifdef DEBUG
fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
#endif
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (AX25_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
}
*
* Alan Cox <Alan.Cox@linux.org>
*
- * $Id: ddp.c,v 1.4 1998/11/15 20:09:25 freitag Exp $
+ * $Id: ddp.c,v 1.5 1998/11/17 15:16:35 freitag Exp $
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
static char buf[64];
if (sap->sa_family != AF_APPLETALK)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (ddp_print(sap->sa_data));
}
* lib/ether.c This file contains an implementation of the "Ethernet"
* support functions.
*
- * Version: $Id: ether.c,v 1.4 1998/11/15 20:09:33 freitag Exp $
+ * Version: $Id: ether.c,v 1.5 1998/11/17 15:16:37 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (pr_ether(sap->sa_data));
}
* lib/fddi.c This file contains an implementation of the "FDDI"
* support functions.
*
- * Version: $Id: fddi.c,v 1.4 1998/11/15 20:09:35 freitag Exp $
+ * Version: $Id: fddi.c,v 1.5 1998/11/17 15:16:39 freitag Exp $
*
* Author: Lawrence V. Stefani, <stefani@lkg.dec.com>
*
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (pr_fddi(sap->sa_data));
}
* NET-3 Networking Distribution for the LINUX operating
* system. (net-tools, net-drivers)
*
- * Version: $Id: getroute.c,v 1.3 1998/11/15 20:09:47 freitag Exp $
+ * Version: $Id: getroute.c,v 1.4 1998/11/17 15:16:42 freitag Exp $
*
* Author: Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
* Copyright 1999 Bernd Eckenfels, Germany
int found = E_NOTFOUND, rc;
char buf[256];
- strncpy(buf, afname, sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
+ safe_strncpy(buf, afname, sizeof(buf));
tmp1 = buf;
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return (strncpy(buf, _("[NONE SET]"), 64));
+ return (safe_strncpy(buf, _("[NONE SET]"), 64));
return (pr_hippi(sap->sa_data));
}
* support functions for the net-tools.
* (NET-3 base distribution).
*
- * Version: $Id: inet.c,v 1.5 1998/11/15 20:10:27 freitag Exp $
+ * Version: $Id: inet.c,v 1.6 1998/11/17 15:16:47 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buff[128];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buff, _("[NONE SET]"), sizeof(buff));
+ return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));
if (INET_rresolve(buff, (struct sockaddr_in *) sap, numeric) != 0)
return (NULL);
return (buff);
* support functions for the net-tools.
* (most of it copied from lib/inet.c 1.26).
*
- * Version: $Id: inet6.c,v 1.4 1998/11/15 20:10:37 freitag Exp $
+ * Version: $Id: inet6.c,v 1.5 1998/11/17 15:16:49 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buff[128];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buff, _("[NONE SET]"), sizeof(buff));
+ return safe_strncpy(buff, _("[NONE SET]"), sizeof(buff));
if (INET6_rresolve(buff, (struct sockaddr_in6 *) sap, numeric) != 0)
return (NULL);
return (buff);
if (*args == NULL)
return (usage());
- target[(sizeof target) - 1] = 0;
- strncpy(target, *args++, (sizeof target) - 1);
+ safe_strncpy(target, *args++, (sizeof target));
/* Clean out the RTREQ structure. */
memset((char *) &rt, 0, sizeof(struct rtentry));
args++;
if (!*args || mask_in_addr(rt))
return (usage());
- netmask[(sizeof netmask) - 1] = 0;
- strncpy(netmask, *args, (sizeof netmask) - 1);
+ safe_strncpy(netmask, *args, (sizeof netmask));
if ((isnet = inet_aftype.input(0, netmask, &mask)) < 0) {
inet_aftype.herror(netmask);
return (E_LOOKUP);
return (usage());
if (rt.rt_flags & RTF_GATEWAY)
return (usage());
- gateway[(sizeof gateway) - 1] = 0;
- strncpy(gateway, *args, (sizeof gateway) - 1);
+ safe_strncpy(gateway, *args, (sizeof gateway));
if ((isnet = inet_aftype.input(0, gateway, &rt.rt_gateway)) < 0) {
inet_aftype.herror(gateway);
return (E_LOOKUP);
static char buf[64];
if (sap->sa_family != AF_IPX)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (IPX_print(sap->sa_data));
}
/*
* lib/loopback.c This file contains the general hardware types.
*
- * Version: $Id: loopback.c,v 1.3 1998/11/15 20:11:06 freitag Exp $
+ * Version: $Id: loopback.c,v 1.4 1998/11/17 15:16:54 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (pr_unspec(sap->sa_data));
}
* lib/netrom.c This file contains an implementation of the "NET/ROM"
* support functions for the NET-2 base distribution.
*
- * Version: $Id: netrom.c,v 1.5 1998/11/15 20:11:25 freitag Exp $
+ * Version: $Id: netrom.c,v 1.6 1998/11/17 15:16:56 freitag Exp $
*
* NOTE: I will redo this module as soon as I got the libax25.a
* library sorted out. This library contains some useful
{
char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (NETROM_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
}
if (islower(c))
c = toupper(c);
if (!(isupper(c) || isdigit(c))) {
- strncpy(netrom_errmsg, _("Invalid callsign"), sizeof(netrom_errmsg));
+ safe_strncpy(netrom_errmsg, _("Invalid callsign"), sizeof(netrom_errmsg));
#ifdef DEBUG
fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
#endif
/* Callsign too long? */
if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
- strncpy(netrom_errmsg, _("Callsign too long"), sizeof(netrom_errmsg));
+ safe_strncpy(netrom_errmsg, _("Callsign too long"), sizeof(netrom_errmsg));
#ifdef DEBUG
fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
#endif
/*
* lib/unix.c This file contains the general hardware types.
*
- * Version: $Id: unix.c,v 1.4 1998/11/15 20:12:31 freitag Exp $
+ * Version: $Id: unix.c,v 1.5 1998/11/17 15:16:58 freitag Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Copyright 1993 MicroWalt Corporation
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (UNSPEC_print(sap->sa_data));
}
static char buf[64];
if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
- return strncpy(buf, _("[NONE SET]"), sizeof(buf));
+ return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
return (UNIX_print(sap->sa_data));
}
/* Copyright 1998 by Andi Kleen. Subject to the GPL. */
-/* $Id: util.c,v 1.3 1998/11/15 20:12:35 freitag Exp $ */
+/* $Id: util.c,v 1.4 1998/11/17 15:17:02 freitag Exp $ */
#include <stdio.h>
#include <stdlib.h>
-#include "util.h"
+#include <string.h>
#include <sys/utsname.h>
+#include "util.h"
+
+
static void oom(void)
{
fprintf(stderr, "out of virtual memory\n");
return -1;
return KRELEASE(major, minor, patch);
}
+
+
+/* Like strncpy but make sure the resulting string is always 0 terminated. */
+char *safe_strncpy(char *dst, const char *src, size_t size)
+{
+ dst[size-1] = '\0';
+ return strncpy(dst,src,size-1);
+}
int nstrcmp(const char *, const char *);
+
+char *safe_strncpy(char *dst, const char *src, size_t size);
+