diff options
author | mav <mav@FreeBSD.org> | 2008-06-22 21:22:25 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2008-06-22 21:22:25 +0000 |
commit | 6aae4674ed0b1f59bead6c8c98b63b331cb4275e (patch) | |
tree | 08d26bab74e1d145a29d14fff95f1da17e9a04ec /sbin | |
parent | 07ce1984c9cf65a1d8c6e33dcdb37296c98131e5 (diff) | |
download | FreeBSD-src-6aae4674ed0b1f59bead6c8c98b63b331cb4275e.zip FreeBSD-src-6aae4674ed0b1f59bead6c8c98b63b331cb4275e.tar.gz |
Use strdup() instead of static buffer allocation to avoid 128 bytes limit
on -redirect_XXX arguments length.
PR: bin/86647
Submitted by: Stephen Hurd <shurd@sasktel.net>
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/natd/natd.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sbin/natd/natd.c b/sbin/natd/natd.c index 7a8d164..64d612e 100644 --- a/sbin/natd/natd.c +++ b/sbin/natd/natd.c @@ -1564,7 +1564,7 @@ static void Usage () void SetupPortRedirect (const char* parms) { - char buf[128]; + char *buf; char* ptr; char* serverPool; struct in_addr localAddr; @@ -1583,7 +1583,9 @@ void SetupPortRedirect (const char* parms) int i; struct alias_link *aliaslink = NULL; - strlcpy (buf, parms, sizeof(buf)); + buf = strdup (parms); + if (!buf) + errx (1, "redirect_port: strdup() failed"); /* * Extract protocol. */ @@ -1700,12 +1702,14 @@ void SetupPortRedirect (const char* parms) ptr = strtok(NULL, ","); } } + + free (buf); } void SetupProtoRedirect(const char* parms) { - char buf[128]; + char *buf; char* ptr; struct in_addr localAddr; struct in_addr publicAddr; @@ -1714,7 +1718,9 @@ SetupProtoRedirect(const char* parms) char* protoName; struct protoent *protoent; - strlcpy (buf, parms, sizeof(buf)); + buf = strdup (parms); + if (!buf) + errx (1, "redirect_port: strdup() failed"); /* * Extract protocol. */ @@ -1756,11 +1762,13 @@ SetupProtoRedirect(const char* parms) */ (void)LibAliasRedirectProto(mla, localAddr, remoteAddr, publicAddr, proto); + + free (buf); } void SetupAddressRedirect (const char* parms) { - char buf[128]; + char *buf; char* ptr; char* separator; struct in_addr localAddr; @@ -1768,7 +1776,9 @@ void SetupAddressRedirect (const char* parms) char* serverPool; struct alias_link *aliaslink; - strlcpy (buf, parms, sizeof(buf)); + buf = strdup (parms); + if (!buf) + errx (1, "redirect_port: strdup() failed"); /* * Extract local address. */ @@ -1805,6 +1815,8 @@ void SetupAddressRedirect (const char* parms) ptr = strtok(NULL, ","); } } + + free (buf); } void StrToAddr (const char* str, struct in_addr* addr) |