From b96be2bd048ecbb6066170b0f55f916b9af7b80c Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Mon, 20 Aug 2001 02:27:11 +0000 Subject: cope with sa_len < sizeof(struct sockaddr). From: Patrik Lindergren --- lib/libc/net/getifaddrs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/libc/net/getifaddrs.c') diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c index 5c9c337f711..ca69af8b9e4 100644 --- a/lib/libc/net/getifaddrs.c +++ b/lib/libc/net/getifaddrs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getifaddrs.c,v 1.5 2001/07/04 19:43:16 deraadt Exp $ */ +/* $OpenBSD: getifaddrs.c,v 1.6 2001/08/20 02:27:10 itojun Exp $ */ /* * Copyright (c) 1995, 1999 @@ -213,7 +213,10 @@ getifaddrs(struct ifaddrs **pif) dcnt += SA_RLEN(sa); ncnt += sizeof(ifr->ifr_name) + 1; - ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa)); + if (SA_LEN(sa) < sizeof(*sa)) + ifr = (struct ifreq *)(((char *)sa) + sizeof(*sa)); + else + ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa)); } #endif /* NET_RT_IFLIST */ -- cgit v1.2.3