From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30999 invoked from network); 12 Oct 2020 16:45:48 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 12 Oct 2020 16:45:48 -0000 Received: (qmail 9220 invoked by uid 550); 12 Oct 2020 16:45:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7355 invoked from network); 12 Oct 2020 16:44:17 -0000 From: Jouni Roivas To: , Date: Mon, 12 Oct 2020 19:43:42 +0300 Message-ID: <20201012164342.2987876-1-jouni.roivas@tuxera.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201012163031.GA2950028@tuxera.com> References: <20201012163031.GA2950028@tuxera.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [87.92.44.32] X-ClientProxiedBy: tuxera-exch.ad.tuxera.com (10.20.48.11) To tuxera-exch.ad.tuxera.com (10.20.48.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-10-12_14:2020-10-12,2020-10-12 signatures=0 X-Proofpoint-Spam-Details: rule=mpy_notspam policy=mpy score=0 spamscore=0 bulkscore=0 mlxlogscore=575 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010120129 Subject: [musl] [PATCH v2] avoid writing two iov in __stdio_write backend when not needed formally, calling writev with a zero-length first iov component should behave identically to calling write on just the second component, but presence of a zero-length iov component has triggered bugs in some kernels. --- src/stdio/__stdio_write.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index d2d89475..eedce03a 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -11,6 +11,10 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) size_t rem = iov[0].iov_len + iov[1].iov_len; int iovcnt = 2; ssize_t cnt; + if (iov[0].iov_len == 0) { + iov++; + iovcnt--; + } for (;;) { cnt = syscall(SYS_writev, f->fd, iov, iovcnt); if (cnt == rem) { -- 2.25.1