From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10511 Path: news.gmane.org!.POSTED!not-for-mail From: Daniel Sabogal Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] fix getservby*_r result pointer value on error Date: Fri, 23 Sep 2016 21:10:07 -0400 Message-ID: <20160924011007.27527-1-dsabogalcc@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1474679434 13082 195.159.176.226 (24 Sep 2016 01:10:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Sep 2016 01:10:34 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10524-gllmg-musl=m.gmane.org@lists.openwall.com Sat Sep 24 03:10:30 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bnbU5-0002q6-DG for gllmg-musl@m.gmane.org; Sat, 24 Sep 2016 03:10:29 +0200 Original-Received: (qmail 17641 invoked by uid 550); 24 Sep 2016 01:10:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17609 invoked from network); 24 Sep 2016 01:10:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=zbPDt/T2AwRwgFtyFUGGwRLpzMWiCn6tBUwDLBiUJGw=; b=S7CgINVxm953Qwgqt+kb0h2r9GWz79KFO4YVP2Nk+nGO/Jz6RRbfFdpoObe1bsPrxT Y5u//USbecgZWXxTBeDqxnrquZLWcb9GHPYapkt3wFWpK/YP5M5VPy+Go/i8dJcTeKQZ jS6v2for/LNggLwKciytPbK0CtM8aX7dLt1fJYb0HexpFYKVW+V+ySZbxguZqK1aof44 SxRxuMWDHsITlfAhtm8uXnimCF3vuXOqyyLpjjoUE1aKZ8tzyK4X9Ube1fHi4zbalNVq FH/iLr64+TtkcXfXcRk/Yk0JwCmBMPPyX/UuGhQWlgJeBraQOgizCYEwqeVzL3prSQPz IR2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=zbPDt/T2AwRwgFtyFUGGwRLpzMWiCn6tBUwDLBiUJGw=; b=m8zncT3c4sWRt0xIam1cgUn/7H/qcmnG5mCPS2mVRlJuJ7YRUlohNidrv7wLmf9EDt 4pBkcrB9P9wFLoxEIBg8b1juLAcX3gR6cwvICml0MPYshgPvAC0WSND2xk2gW91IVNIX EH4w7E6Jk8qLLZ8gzcZbix0wkijWhy5Dq5Bpb2uHKuo4GdUU4ITv5hGp9Spf3J2JlI78 JLw9WqITIVykpTImf0Kcu62zLUEv8tLjqsI9xXESd/vZaHlDsMjdKBq8UyPtdnpCKLnB nImBrcHK9owfwuoMz6wJhfBw2z52lLV+6L1ekO+0QFjg2iH6oUMogjdLoRWqBvULlq6M hgeA== X-Gm-Message-State: AE9vXwNpmXe4uKbLSmXyXrUZ9u+m36d/cTuodxjJ9JVFWjjQLPuzlrG29oTYwypvG+QJzA== X-Received: by 10.202.93.197 with SMTP id r188mr14542381oib.88.1474679414497; Fri, 23 Sep 2016 18:10:14 -0700 (PDT) X-Mailer: git-send-email 2.10.0 Xref: news.gmane.org gmane.linux.lib.musl.general:10511 Archived-At: this is a clone of the fix to the gethostby*_r functions in commit fe82bb9b921be34370e6b71a1c6f062c20999ae0. the man pages document that the getservby*_r functions set this pointer to NULL if there was an error or if no record was found. --- src/network/getservbyname_r.c | 2 ++ src/network/getservbyport_r.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/network/getservbyname_r.c b/src/network/getservbyname_r.c index 056c2f3..ad3d616 100644 --- a/src/network/getservbyname_r.c +++ b/src/network/getservbyname_r.c @@ -15,6 +15,8 @@ int getservbyname_r(const char *name, const char *prots, struct service servs[MAXSERVS]; int cnt, proto, align; + *res = 0; + /* Align buffer */ align = -(uintptr_t)buf & ALIGN-1; if (buflen < 2*sizeof(char *)+align) diff --git a/src/network/getservbyport_r.c b/src/network/getservbyport_r.c index a0a7cae..0ae0e41 100644 --- a/src/network/getservbyport_r.c +++ b/src/network/getservbyport_r.c @@ -20,6 +20,7 @@ int getservbyport_r(int port, const char *prots, if (r) r = getservbyport_r(port, "udp", se, buf, buflen, res); return r; } + *res = 0; /* Align buffer */ i = (uintptr_t)buf & sizeof(char *)-1; -- 2.10.0