From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13815 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Forney Newsgroups: gmane.linux.lib.musl.general Subject: Re: Error in getaddrinfo()? Date: Tue, 19 Feb 2019 13:09:21 -0800 Message-ID: References: <20190219202700.GB19969@voyager> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="186349"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-13831-gllmg-musl=m.gmane.org@lists.openwall.com Tue Feb 19 22:09:39 2019 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.89) (envelope-from ) id 1gwCe1-000mJV-MN for gllmg-musl@m.gmane.org; Tue, 19 Feb 2019 22:09:37 +0100 Original-Received: (qmail 16025 invoked by uid 550); 19 Feb 2019 21:09:35 -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 16003 invoked from network); 19 Feb 2019 21:09:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=nqPmVnxwl62IxUMtze+Jdj9oDPcbWs+VpyO+vZcLKUs=; b=hTNudUw7qOscSVFjDJefydwN3rn4CnR61eit0bVGLTXtwBf9Fv750VDax6AY00sI6v sMzLNuShRwl58eLrf2w6m6tHDeL/5tKo7Kf8nG+IeyOWT//0J8Pi1suIaSr5bjVM8nh9 OS3VpYgKqgiMCZAQ8PZp9WN8ivayxQqDMcakt7eoMyDA4oJ1S3kpcwS/W1xSFAEz52aw nSu7Fg36FGKmS3RI7GqMxo64SlQbRof+DAexJ8ocjKpVFWm3FRdrJbNYbSJH5wxcs4vj 3gJRWMYVbd2k8zPB3x4q22rCW0fYUt/9Pcfz+VLTikj5oCWQHLLzc+LkBWQqpt0U8sVI zWyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=nqPmVnxwl62IxUMtze+Jdj9oDPcbWs+VpyO+vZcLKUs=; b=TFDz8GYqwN+RenoFvZBUJNkumbJ9IAWKWiAHlZONyuvLaKpV9paKHmpHuftk+gYY8C xL1fGH17xCMyFXFBcx5UhyduSyfKTQR+awxdtELpUv32vPLOKZ43xt9Nq+1zsuAnyUfv TZfbSKd1rGiOb01aW5og+aXdTaBgQjbk7x8Dd7IgkqzGORRQtyU3ur1/9eN85+Zk0Ub/ DCdbNqguoodXYY07aFtbAJc3kkjw4QNdHKsNj+NzPpzNA+ifvb5pvZ0CsxUqNf2CD+pi RodFRO5wrg30aCi7xJ6PgxlvjAOhUgACWo87Qe8ZgOjInJaUvOi/04JIbkXPMtK6Vs/Q mqXA== X-Gm-Message-State: AHQUAuaio68alcAUmBC9mQx1cqig0hTbDOiuGEHRppOWpxjF59S2ZQSz 242Vqe7ZHGP30n+f/jHVgYKCRHzuf2DDj/V7k3zg8hOYnKA= X-Google-Smtp-Source: AHgI3IYaux/eNB2Z0k8khSzpsH+T52qj2tagUXiBJwbEAAA1bbI2KSL5UtlhODmTGBwOyFcvhQ3TlDBpihOKlHKfcOg= X-Received: by 2002:a5b:403:: with SMTP id m3mr4037652ybp.298.1550610562140; Tue, 19 Feb 2019 13:09:22 -0800 (PST) X-Originating-IP: [2601:647:5180:35d7:16dd:a9ff:fee7:6b79] In-Reply-To: <20190219202700.GB19969@voyager> Xref: news.gmane.org gmane.linux.lib.musl.general:13815 Archived-At: On 2019-02-19, Markus Wichmann wrote: > And while we're on the subject, a few lines later we get > > .ai_next = &out[k+1].ai }; > > Now, for the last k, isn't this calculation undefined? The array index > is out of bounds, then. It won't matter what is calculated here, since > the last .ai_next is explicitly nulled a few lines further down, but the > calculation might invoke undefined behavior, and these last few years > compilers have gotten really agressive about that. I don't think it is undefined behavior, as long as it is not dereferenced. See http://port70.net/~nsz/c/c11/n1570.html#6.5.6p8: "If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined. If the result points one past the last element of the array object, it shall not be used as the operand of a unary * operator that is evaluated."