Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/lpr/common_source avoid NULL pointer access when rp...
details: https://anonhg.NetBSD.org/src/rev/1aaffa221615
branches: trunk
changeset: 485284:1aaffa221615
user: itojun <itojun%NetBSD.org@localhost>
date: Mon Apr 24 02:53:05 2000 +0000
description:
avoid NULL pointer access when rp=<ipv4 numberic address> (no ai_canonname).
From: hiro%takechi.org@localhost
XXX checkremote() should be improved. gethostname -> getaddrinfo is
not the right thing to do, we cannot assume DNS FQDNs is configured
as hostname. if the goal here is to check if it is really remote or not,
getifaddrs() is the way to go.
diffstat:
usr.sbin/lpr/common_source/common.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (46 lines):
diff -r 2c9da287d6e8 -r 1aaffa221615 usr.sbin/lpr/common_source/common.c
--- a/usr.sbin/lpr/common_source/common.c Sun Apr 23 23:21:32 2000 +0000
+++ b/usr.sbin/lpr/common_source/common.c Mon Apr 24 02:53:05 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.18 2000/02/18 03:53:16 itojun Exp $ */
+/* $NetBSD: common.c,v 1.19 2000/04/24 02:53:05 itojun Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: common.c,v 1.18 2000/02/18 03:53:16 itojun Exp $");
+__RCSID("$NetBSD: common.c,v 1.19 2000/04/24 02:53:05 itojun Exp $");
#endif
#endif /* not lint */
@@ -321,10 +321,12 @@
hints.ai_socktype = SOCK_STREAM;
res = NULL;
error = getaddrinfo(hname, NULL, &hints, &res);
- if (error) {
+ if (error || !res->ai_canonname) {
(void)snprintf(errbuf, sizeof(errbuf),
"unable to get official name for local machine %s: "
"%s", hname, gai_strerror(error));
+ if (res)
+ freeaddrinfo(res);
return errbuf;
} else {
(void)strncpy(hname, res->ai_canonname,
@@ -340,10 +342,12 @@
hints.ai_socktype = SOCK_STREAM;
res = NULL;
error = getaddrinfo(RM, NULL, &hints, &res);
- if (error) {
+ if (error || !res->ai_canonname) {
(void)snprintf(errbuf, sizeof(errbuf),
"unable to get official name for local machine %s: "
"%s", RM, gai_strerror(error));
+ if (res)
+ freeaddrinfo(res);
return errbuf;
}
Home |
Main Index |
Thread Index |
Old Index