From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6DE4A208B8 for ; Sun, 13 Aug 2017 04:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750783AbdHMEcq (ORCPT ); Sun, 13 Aug 2017 00:32:46 -0400 Received: from cloud.peff.net ([104.130.231.41]:37262 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750768AbdHMEcp (ORCPT ); Sun, 13 Aug 2017 00:32:45 -0400 Received: (qmail 10998 invoked by uid 109); 13 Aug 2017 04:32:41 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Sun, 13 Aug 2017 04:32:41 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28362 invoked by uid 111); 13 Aug 2017 04:33:04 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with SMTP; Sun, 13 Aug 2017 00:33:04 -0400 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Sun, 13 Aug 2017 00:32:37 -0400 Date: Sun, 13 Aug 2017 00:32:37 -0400 From: Jeff King To: =?utf-8?B?UmVuw6k=?= Scharfe Cc: Simon Ruderich , "git@vger.kernel.org" , Junio C Hamano , Yaroslav Halchenko Subject: Re: [PATCH] strbuf: clear errno before calling getdelim(3) Message-ID: <20170813043237.ndcm77i43ivepo7b@sigill.intra.peff.net> References: <20170809173928.h2ylvg5tp2p5inem@hopa.kiewit.dartmouth.edu> <8e307474-d180-6d98-2c6b-062f2181bd14@web.de> <6d7b0d30-48ea-f79f-78cd-088557ea06ac@web.de> <20170810200502.rutab4z3ft7gcpjz@sigill.intra.peff.net> <20170811075059.nn6lru7uy6s6vpza@ruderich.org> <20170812100252.bhbgg5jjlom7dfl2@ruderich.org> <510f566b-3aee-98fd-9663-d97c3dcfeb96@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <510f566b-3aee-98fd-9663-d97c3dcfeb96@web.de> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote: > But we probably want to check for other errors. They look unlikely > enough that we may get away with something like this: > > - if (errno == ENOMEM) > - die("Out of memory, getdelim failed"); > + if (errno || ferror(fp)) > + die_errno(_("getdelim failed")); > > NB: The other errors are EINVAL (input pointers are NULL or the > stream is invalid) and EOVERFLOW (read more than fits into ssize_t) > according to POSIX and the Linux manpage. Can't we also get any of the errors that fgetc() would return. I.e., any normal read errors? We should return EOF on those, not die (and the caller can check ferror()). -Peff