Dave Dykstra
2001-May-18 19:59 UTC
patch to change sprintf to snprintf in inet_ntop.c for SunOS4
I found that inet_ntop.c was depending on the return value of sprintf to return an int, but on SunOS4 it returns a char *. Snprintf is preferred anyway, so here's a patch to change the calls to use snprintf. Applies cleanly to the current CVS, and it was the only patch I need to apply to get 2.9p1 to build on SunOS4.1.4. On the other hand, I can't see any where inet_ntop is called, and the symbol doesn't appear anywhere in the binaries on SunOS4 or Solaris. Can the file just be deleted? - Dave Dykstra *** inet_ntop.c.O Fri May 18 15:00:35 2001 --- inet_ntop.c Fri May 18 15:01:00 2001 *************** *** 16,22 **** * SOFTWARE. */ ! #include "config.h" #ifndef HAVE_INET_NTOP --- 16,22 ---- * SOFTWARE. */ ! #include "includes.h" #ifndef HAVE_INET_NTOP *************** *** 104,110 **** static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; ! if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) { errno = ENOSPC; return (NULL); } --- 104,110 ---- static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; ! if (snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]) > size) { errno = ENOSPC; return (NULL); } *************** *** 190,196 **** tp += strlen(tp); break; } ! tp += sprintf(tp, "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) --- 190,196 ---- tp += strlen(tp); break; } ! tp += snprintf(tp, sizeof "ffff", "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
Seemingly Similar Threads
- 2.5.6pre1 bombs on Sunos4 in popthelp.c on use of sprintf
- [Bug 74] New: Use of sig_atomic_t breaks SunOS4 compile
- SunOS 4.1.4 "configure: WARNING" for sys/audit.h and sys/dir.h
- [Bug 74] Use of sig_atomic_t breaks SunOS4 compile
- [PATCH] Compilation of tftp-hpa's Git HEAD with no IPv6, and misc