Bug 230382

Summary: www/thttpd REAL_IP patch is IPv4-only
Product: Ports & Packages Reporter: Bjoern A. Zeeb <bz>
Component: Individual Port(s)Assignee: Alexey Dokuchaev <danfe>
Status: Closed FIXED    
Severity: Affects Some People    
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 232348    

Description Bjoern A. Zeeb freebsd_committer freebsd_triage 2018-08-05 16:07:04 UTC
In ports r377229 the thttps REAL_IP patch was added based on something from NginX if I understand the dead link reference correctly.  That cripples IPv6 ready software to IPv4 only.  Here's an entirely untested change to the diff you might want to apply:

                { // Use real IP if available
                cp = &buf[16];
                cp += strspn( cp, " \t" );
-               inet_aton( cp, &(hc->client_addr.sa_in.sin_addr) );
+#ifdef USE_IPV6
+               if (strchr(cp, '.') == NULL)
+                       inet_pton(AF_INET6, cp,
+                           &(hc->client_addr.sa_in6.sin6_addr) );
+               else
+#endif
+                       inet_aton( cp, &(hc->client_addr.sa_in.sin_addr) );
Comment 1 commit-hook freebsd_committer freebsd_triage 2020-02-11 07:07:30 UTC
A commit references this bug:

Author: danfe
Date: Tue Feb 11 07:07:14 UTC 2020
New revision: 525787
URL: https://svnweb.freebsd.org/changeset/ports/525787

Log:
  In r377229, the REAL_IP patch from NginX was added that puts X-Forwarded-For
  into Remote-Addr.  That cripples IPv6 ready software to IPv4 only, let's try
  to fix this.

  PR:		230382
  Submitted by:	bz

Changes:
  head/www/thttpd/Makefile
  head/www/thttpd/files/extra-patch-ip_real
Comment 2 Alexey Dokuchaev freebsd_committer freebsd_triage 2020-02-11 07:08:34 UTC
Applied in ports r525787, thanks!