addrtoname.c (17681) | addrtoname.c (17688) |
---|---|
1/* 2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 453 unchanged lines hidden (view full) --- 462 register u_int i, nlen = nsap[0]; 463 register char *cp; 464 register struct enamemem *tp; 465 466 tp = lookup_nsap(nsap); 467 if (tp->e_name) 468 return tp->e_name; 469 | 1/* 2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 453 unchanged lines hidden (view full) --- 462 register u_int i, nlen = nsap[0]; 463 register char *cp; 464 register struct enamemem *tp; 465 466 tp = lookup_nsap(nsap); 467 if (tp->e_name) 468 return tp->e_name; 469 |
470 tp->e_name = cp = (char *)malloc(nlen * 2 + 2); | 470 tp->e_name = cp = (char *)malloc(nlen * 2 + 2 + (nlen>>1)); |
471 if (cp == NULL) 472 error("isonsap_string: malloc"); 473 474 nsap++; | 471 if (cp == NULL) 472 error("isonsap_string: malloc"); 473 474 nsap++; |
475 *cp++ = '/'; 476 for (i = nlen; (int)--i >= 0;) { | 475 for (i = 0; i < nlen; i++) { |
477 *cp++ = hex[*nsap >> 4]; 478 *cp++ = hex[*nsap++ & 0xf]; | 476 *cp++ = hex[*nsap >> 4]; 477 *cp++ = hex[*nsap++ & 0xf]; |
478 if (((i & 1) == 0) && (i + 1 < nlen)) 479 *cp++ = '.'; |
|
479 } 480 *cp = '\0'; 481 return (tp->e_name); 482} 483 484char * 485tcpport_string(u_short port) 486{ --- 270 unchanged lines hidden --- | 480 } 481 *cp = '\0'; 482 return (tp->e_name); 483} 484 485char * 486tcpport_string(u_short port) 487{ --- 270 unchanged lines hidden --- |