Changeset 295 for trunk/src/sh_utmp.c
- Timestamp:
- Oct 31, 2010, 10:36:04 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_utmp.c
r290 r295 179 179 char name[UT_NAMESIZE+1]; 180 180 char ut_host[UT_HOSTSIZE+1]; 181 char ut_ship[ 16]; /* IP address */181 char ut_ship[SH_IP_BUF]; /* IP address */ 182 182 time_t time; 183 183 struct log_user * next; … … 454 454 455 455 #ifdef HAVE_UTADDR 456 #ifdef HAVE_INET_ATON 457 static char * my_inet_ntoa(struct in_addr in) 458 { 459 return /*@-unrecog@*/inet_ntoa(in)/*@+unrecog@*/; 460 } 461 #else 462 static char * my_inet_ntoa(struct in_addr in) 463 { 464 unsigned char a, b, c, d; 465 static char foo[16]; 466 char bar[4]; 467 memcpy (bar, &(in.s_addr), 4); /* memory alignment (?) */ 468 memcpy (&a, &bar[0], 1); 469 memcpy (&b, &bar[1], 1); 470 memcpy (&c, &bar[2], 1); 471 memcpy (&d, &bar[3], 1); 472 sprintf(foo, _("%d.%d.%d.%d"), /* known to fit */ 473 (int) a, (int) b, (int) c, (int) d); 474 return foo; 456 #ifdef HAVE_UTADDR_V6 457 static char * my_inet_ntoa(SINT32 * ut_addr_v6, char * buf, size_t buflen) 458 { 459 struct in_addr in; 460 461 buf[0] = '\0'; 462 463 if (0 == (ut_addr_v6[1] + ut_addr_v6[2] + ut_addr_v6[3])) 464 { 465 memcpy(&in, ut_addr_v6, sizeof(struct in_addr)); 466 sl_strlcpy(buf, inet_ntoa(in), buflen); 467 } 468 else 469 { 470 inet_ntop(AF_INET6, ut_addr_v6, buf, buflen); 471 } 472 return buf; 473 } 474 #else 475 static char * my_inet_ntoa(SINT32 ut_addr, char * buf, size_t buflen) 476 { 477 struct in_addr in; 478 479 buf[0] = '\0'; 480 481 memcpy(&in, ut_addr, sizeof(struct in_addr)); 482 sl_strlcpy(buf, inet_ntoa(in), buflen); 483 return buf; 475 484 } 476 485 #endif … … 915 924 #endif 916 925 #ifdef HAVE_UTADDR 917 /*@-type@*//* ut_addr does exist !!! */ 918 { 919 struct in_addr saddr; 920 memcpy (&saddr, &(ut->ut_addr), sizeof(struct in_addr)); 921 (void) sl_strlcpy((char*)(user->ut_ship), 922 my_inet_ntoa(saddr), 16); 923 } 924 /*@+type@*/ 926 #ifdef HAVE_UTADDR_V6 927 my_inet_ntoa(ut->ut_addr_v6, user->ut_ship, SH_IP_BUF); 928 #else 929 my_inet_ntoa(ut->ut_addr, user->ut_ship, SH_IP_BUF); 930 #endif 925 931 #endif 926 932 user->time = ut->ut_time; … … 1059 1065 #endif 1060 1066 #ifdef HAVE_UTADDR 1061 sl_strlcpy(user->ut_ship,my_inet_ntoa((struct in_addr)ut->ut_addr),16); 1067 #ifdef HAVE_UTADDR_V6 1068 my_inet_ntoa(ut->ut_addr_v6, user->ut_ship, SH_IP_BUF); 1069 #else 1070 my_inet_ntoa(ut->ut_addr, user->ut_ship, SH_IP_BUF); 1071 #endif 1062 1072 #endif 1063 1073 user->time = ut->ut_time;
Note:
See TracChangeset
for help on using the changeset viewer.