From patchwork Thu Nov 21 22:20:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UGV0ciBNZW7FocOtaw==?= X-Patchwork-Id: 101707 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 83DC93857BBA for ; Thu, 21 Nov 2024 22:20:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83DC93857BBA Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AMgD8Rkh X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1D5DF385802C for ; Thu, 21 Nov 2024 22:20:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D5DF385802C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1D5DF385802C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732227614; cv=none; b=t0xTSPjXBDXYqvr45x6IZR0g3p8ldBqZucreT71er+vy74OIVmoG5OEQ5WiHqnYha6L3EjYgejo/XNB0wpqFKaQnHkbqHAd7pONvjkp99HfjimKOJPpZVM7uKQkocQBZTQ6i9iYOIbN/GevoBrnVHC5OkTGxN3J34aYAr1A7IU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732227614; c=relaxed/simple; bh=xDByb1xyzaYT0GfK6PSbn9niQX6Az5Jf8PAC8KyY3JM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=NG7d/M3FHWe81bd6UV7EmVq30ZduEhFuH4xYpq2vjCo4THVOcWzAAa+wr07UNlvvO2t3NjdBwLh6r6aPSX+6Kf4vvf0rP+yJ7m5Cgw6MeS5WrmONsy5ps/Nj1RrWRQCsh54fYdBgrWUS4vTdTEVcAQR9OnumPUgaVWTrxNhs0ng= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D5DF385802C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732227613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type:autocrypt:autocrypt; bh=4aIy6/jXHXNWk3JVkt+w4+G/+no+bcS41aW35jJMXX8=; b=AMgD8RkhKkQPCa2uGPEi+s3tSgfn1buiXZeuOMA2huMVDqnRe6wL9wZpYtfXnkKeBNxfNj rokj2+RIb8kOHuTtUduCCPKbd+SaKCtAFyI6ioyneXmObxAyyjuHvbdAcsBRYGBOtVWW7b sDmwVg/YVi2LF7zByhqwa3jNgRzVF9A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-MA64cCkiNNmQ3HYw4oJ8Cg-1; Thu, 21 Nov 2024 17:20:11 -0500 X-MC-Unique: MA64cCkiNNmQ3HYw4oJ8Cg-1 X-Mimecast-MFC-AGG-ID: MA64cCkiNNmQ3HYw4oJ8Cg Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43151e4ef43so9522305e9.3 for ; Thu, 21 Nov 2024 14:20:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732227609; x=1732832409; h=autocrypt:subject:from:cc:to:content-language:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=42kpfFh7K5EWnzneYG3r7tK/VZZJucG1OHlt4HYmGzc=; b=BIy7ND3z761E2i4x0VItayLfv5JoXslq1IDAdn4eDNSE6exNcAbenTAecJJ+nF8AT7 bYRXwIjunmv2yND4mkTKnZ2j5n1PXgG5tpKRqSBJm2yqEHGSqz/1a3/oo3+UVIERKYL5 8i8VakLaHp0pkczJQf/7eS3I9696YV8Z6oRfOo+N5+qNEBP9IQCF8s2ZyhWgq7bZndzz IaMtezmWjgwY5Ud1QZu3AQoAky58Yk5USaE7+PpmRlzkR6PCFFVVExZWRpeBbi9IQZch Pjtn2xiaw91Jnz1mpLsnehWwmkBmOQLSjWk6OL1sOFEeDwT9Nudq2UNCc/yEv38sh28I 7P8g== X-Gm-Message-State: AOJu0Ywv4YzPO4pFdO6f/pd+b8UURVFQtihQci800iEC/9xX4UqOQlii RtVNcp0xlkMEy7aaTIv/7gXKeY12kfnEnm/uD9iJ3kA78YjMdC626FSzwNBYBYWX0EtBEZZcHMK 3Nh4hEfyJ3yQITcJk6MDCr9rqWTtvfBjuUhIFzgGNla+MT4NJb8nTyklHa6Vdgh1myjEJGBzKdu PUxXI2DyDSpK3tJWYPNzx5TQGPeBy+EZ2R9uYuRpCc2A== X-Gm-Gg: ASbGnctHpxU9P6M7bpGhO9beLb6ojb6OKY/bL6BGJ659NTJJ4uiwc/f5YLVcHoV69SC iR/GtPr18pdEpqupAo7fINYoVA+/5nevuF/N0FZYuc8YUZM6pv8fa8kzOs8pbsIdGpaewlZjJgg g17s8yIRt7A1scfx1V9y7TyoNbk9dP0VX+bb2Vdmqq/LuMqgpytYgGinlcvU5C9ye5hB/k/rRw2 dWtDMDAxwR036WGMy7opWmAhIyYYHhEJJF5AbolJ1A7AKUx2Wq/ZfRs5yobq6gxUNSIKKqh4/SS X-Received: by 2002:a05:600c:1c0b:b0:431:5863:4240 with SMTP id 5b1f17b1804b1-433ce49153amr3296755e9.24.1732227609551; Thu, 21 Nov 2024 14:20:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrqc7da8z5qPssC39sbvKtiIt0+E6O36Z5e182vGeH9TEnQyGs0ZkJe5g82NCOZ6de6yuEiQ== X-Received: by 2002:a05:600c:1c0b:b0:431:5863:4240 with SMTP id 5b1f17b1804b1-433ce49153amr3296575e9.24.1732227609179; Thu, 21 Nov 2024 14:20:09 -0800 (PST) Received: from [10.43.2.229] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-433cde110cfsm6300385e9.11.2024.11.21.14.20.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 14:20:08 -0800 (PST) Message-ID: Date: Thu, 21 Nov 2024 23:20:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: libc-alpha@sourceware.org Cc: Martin Pool , Shawn Landden From: =?utf-8?b?UGV0ciBNZW7FocOtaw==?= Subject: [PATCH] getaddrinfo() does not detect invalid numeric services (bug 16208) Autocrypt: addr=pemensik@redhat.com; keydata= xsDNBF17vwQBDACso9gM0++XOzm/b//dGE1bgYyIch8xqCDHe2YXDUL2a65LCmNQUnS7PTxf 8psG4DdBayWlRvA/33L3YQD8gULaZX/KsHbSQov4Np4E2rG9PCljcDqHFCKjHEmmzQ86Z4+r euHoTwUpEroz2xa1XAIsy4fjqro0GHc6H3BVwXQ8Vfrmllq6tW+ubegI/tZSDDfOlnkHyMsh /mX893qn1Sb+A/RqyDDV6voAv4YfoNJyDfBB0jMshEiSLO+S0vspw42ElbAdLO6SHOX8Dy/a yPVTGDe2Jopy3YrbUWtu5HIs8X0vsKbF6tegO1l/m1y3t2Aa153k6NKOWv+79iNiY2ygGefm o1TRzlS/d+xacOxnGO3RCSlvm3xDEUuqNqrSQNF2yVRYAMwh75VWefeTu+/erXR4MGDpTTSA Ebaen0+uuiG4LGCNz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aXUHyr47y3IoNXNlc0s7dg542OA6m2FkvQYgfbZlQb66J0PTAl31zvYN/G2C024DDqU1wOpV hn1RYkoc0UTAse2IdP/t2mqE4me2gZ7NrjWwFSzXlGIh08T7KxHLrGtA3Mm2I3XnPHO1ppf6 xBoeGMfESeNfoR8sGWOnYyd52CKdnp7DtJ3TlGLlafnkauwHrHnHdkJb4pkKjXKavKy/DjUG yWG74jexhwARAQABwsD8BBgBCAAmAhsMFiEE38+QjbfIfo5SmSW8STHKW2yfxcsFAmTxxYsF CQs4bYcACgkQSTHKW2yfxct9DAv/YIBB1dENrLjMhh+Y11s++p2VFeP4gxawrrXc6tXRcfXj aEvubqNTG34HIUhIIFKbl7S4HGLFhcCtLdzn6nW3e/jH6Gen2InSLHyHVUpt8U0ysSKFoTpM BgP95IWYhx2I3FtKBpjSmTx/Vwdgf1D2QBBLwEWFYazuUIVY8IxwWOlfwpN56jujdSPrcxZD HGDz5gBKy9bKaoTQT6IZXHTanTi7XVJShtWJsX9pot3dPMi+5W+mTaocEc+gnPyEKI9WoQJ/ Ow5At3mQqJ1CEaRF4BXDK0bXIzOrejHDhv4n3RSrvnFlV2e+BcbfS7uj4rYRPsjZ4nffFpog CiM0Yg6RihUbZ8h6BMghOt0F07LAV3ISpaPeVsp4F6pnFedS5NgMufiBSopSJTc8wLked9E3 PlSxMeSMfi21E/eLg024Wx2c9JdKNFrYGEkgdr+w9WBA7AMKFCIQKDAwb3vPgxO3owDNC+ka AJs6m+d2kZSDzqUdFMZLrqbp0vt3GnIF8l3Y X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: CYgpAMpFUWVeQsQzCU4OwOho5BwycnyvSbcN02yeNEI_1732227610 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Hi! I have found relatively simple fix at bug 16208. I got that and applied that to recent glibc. Fixed constants a bit. Quite self contained functionality and safe to merge, IMO. From 99bfa52cdbc0d90236b922436220c5e586d46e6a Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sat, 23 Nov 2013 08:19:58 -0800 Subject: [PATCH] getaddrinfo: return EAI_SERVICE when TCP or UDP port out of range (bug 16208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed to use constant and fixed typo. Allow also service=0, especially useful for AI_PASSIVE. Reported-by: Martin Pool Signed-off-by: Shawn Landden Signed-off-by: Petr Menšík --- nss/getaddrinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c index 3ccd3905fa..cd99775b0e 100644 --- a/nss/getaddrinfo.c +++ b/nss/getaddrinfo.c @@ -2377,6 +2377,12 @@ getaddrinfo (const char *name, const char *service, gaih_service.num = -1; } + else if ((hints->ai_family == AF_INET || hints->ai_family == AF_INET6) + && (hints->ai_socktype == SOCK_STREAM || hints->ai_socktype == SOCK_DGRAM) + && gaih_service.num > UINT16_MAX) + { + return EAI_SERVICE; + } pservice = &gaih_service; } -- 2.47.0