git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macroses

From
Bbrilliantov@inbox.ru <brilliantov@inbox.ru>
Date
Aug 25, 2015, 10:34 UTC
Message-ID
<1440498879-12382-1-git-send-email-brilliantov@inbox.ru>
From: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>
Signed-off-by: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>
---
 compat/inet_ntop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index 90b7cc4..fcd3b15 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -47,7 +47,7 @@ static const char *
 inet_ntop4(const u_char *src, char *dst, size_t size)
 {
 	static const char fmt[] = "%u.%u.%u.%u";
-	char tmp[sizeof "255.255.255.255"];
+	char tmp[INET_ADDRSTRLEN];
 	int nprinted;
 
 	nprinted = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
@@ -78,7 +78,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
 	 * Keep this in mind if you think this function should have been coded
 	 * to use pointer overlays.  All the world's not a VAX.
 	 */
-	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+	char tmp[INET6_ADDRSTRLEN], *tp;
 	struct { int base, len; } best, cur;
 	unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
 	int i;
-- 
2.1.4
Next: Johannes Schindelin
Message 1 of 2 in “compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macroses”
  1. compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macrosesbrilliantov@inbox.ru, Aug 25, 2015
  2. Johannes SchindelinAug 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.