Permalink
Browse files

changed the static buffer in if_name() to an array of array

to be more context safe.
  • Loading branch information...
1 parent 22a6541 commit b8ed1eeecf31be89f90816df894e9298ef32cf92 jinmei committed Jul 16, 2000
Showing with 10 additions and 5 deletions.
  1. +10 −5 kame/sys/net/net_osdep.c
@@ -1,4 +1,4 @@
-/* $KAME: net_osdep.c,v 1.6 2000/07/02 15:00:51 itojun Exp $ */
+/* $KAME: net_osdep.c,v 1.7 2000/07/16 17:09:57 jinmei Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -56,13 +56,18 @@ const char *
if_name(ifp)
struct ifnet *ifp;
{
- static char nam[IFNAMSIZ + 10]; /*enough?*/
+ static char nam[8][IFNAMSIZ + 10]; /*enough?*/
+ static int ifbufround = 0;
+ register char *cp;
+
+ ifbufround = (ifbufround + 1) & 7;
+ cp = nam[ifbufround];
#ifdef __bsdi__
- sprintf(nam, "%s%d", ifp->if_name, ifp->if_unit);
+ sprintf(cp, "%s%d", ifp->if_name, ifp->if_unit);
#else
- snprintf(nam, sizeof(nam), "%s%d", ifp->if_name, ifp->if_unit);
+ snprintf(cp, sizeof(nam), "%s%d", ifp->if_name, ifp->if_unit);
#endif
- return nam;
+ return((const char *)cp);
}
#endif

0 comments on commit b8ed1ee

Please sign in to comment.