patch to change sprintf to snprintf in inet_ntop.c for SunOS4
Dave Dykstra
dwd at bell-labs.com
Sat May 19 05:59:24 EST 2001
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))
More information about the openssh-unix-dev
mailing list