From owner-freebsd-current@freebsd.org Wed Jul 20 22:14:09 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9CBBB9FE7B for ; Wed, 20 Jul 2016 22:14:09 +0000 (UTC) (envelope-from darkuranium@gmail.com) Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com [IPv6:2a00:1450:4010:c07::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3009213B9 for ; Wed, 20 Jul 2016 22:14:09 +0000 (UTC) (envelope-from darkuranium@gmail.com) Received: by mail-lf0-x236.google.com with SMTP id b199so47828697lfe.0 for ; Wed, 20 Jul 2016 15:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=TpwLyl/Rrsv2/xHbjbNwckm0/KbZxsdHd+gsydlv6VY=; b=KmVj8RIoynI4z5nmZ37Qt4+Nq8ZvRPxOUgMW4iB7YcUhAuj/JdJ054oTSHCyXgCAiH 6/LcUE0XNSwYDSPmPqHIzv5icBscY0i9nHH/kWAH1sswqQN+FQqolW+f78JBkQ6EZKmk n3Z56b1i3U4BBY3YmX+qoG/QDm0TJmHN5mBCUn+lIfWGi+Ols2SLwah2uWv3Abl7oVaQ qfCA6LNCJhdT+U+2XS85MXX5S1sipFU/TzKGL45JZx8cl5WFFrZ7PCN4sgWBgxXgYXo/ ZFBE76wtMEIWjafTDclg+219laLAqD2GgOdqqDldiWIKu8g3hHYEcNgpmSo+cD1WYDD5 mCSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=TpwLyl/Rrsv2/xHbjbNwckm0/KbZxsdHd+gsydlv6VY=; b=jBYlmVybzPhmBQkbGTe6UHJ9f62UOON1sUZVPsvC/5eoNXSH39Ooa+j84Q73pphMW7 FmO0KIJ42jxpMXiaEEk/dDhyV0YsjX9wMqWFCp4wca8a1KmwntRKCVX9Tq+pD2Slv7ux vNiGRYJonUo/48UM73F29lGDX3soYJ8+ereYJnM/pKDWz3uegzASJEH3/7K9G4XMdzAL ZeV8Wvnr6/JGYWBqr9ykz4dDk7o5G/jfDK4Wh83GkOzSfn1uxu0KPSSpIaMp2ejRrsgj ydZoCWf5mzW/IagjxldEFdfQjDy9wNXiE9lv81xKgEj/yNWGEhu5bQgUK7kBOpEirOf5 y8iw== X-Gm-Message-State: ALyK8tLn0OoqWFYElLbrOItXIgKdELPcSVt/nlHpp/Qv+P3drxvKAF6gAIIMSrbXZ5spfnp7EyXcj5haZ/rNAg== X-Received: by 10.46.32.139 with SMTP id g11mr16594047lji.28.1469052846927; Wed, 20 Jul 2016 15:14:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.160.201 with HTTP; Wed, 20 Jul 2016 15:14:06 -0700 (PDT) In-Reply-To: <201607202023.u6KKNksl055230@gw.catspoiler.org> References: <201607202023.u6KKNksl055230@gw.catspoiler.org> From: =?UTF-8?B?VGltIMSMYXM=?= Date: Thu, 21 Jul 2016 00:14:06 +0200 Message-ID: Subject: Re: UTF-8 by default? To: freebsd-current@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 22:14:09 -0000 On 20 July 2016 at 22:23, Don Lewis wrote: > It passes a fixed-length non-NUL terminated buffer (returned by read(2)) > to mbrtowc(). In addition to the lack of termination, the buffer could > also contain a partial character at its beginning or end if the contents > are UTF-8. > > The Coverity ID is 978825. I don't have access to Coverity, but with boru's help, I managed to check the lines. There is no problem as far as I can tell --- yes, the buffer is not NUL-terminated [1], *BUT* `mbrtowc(3)` takes a `len` argument (which is returned from said `read(2)`), so it never tries to read out of scope [2,3]. The problem might still be elsewhere, though --- the code is somewhat hairy, so I'll give it a closer check tomorrow. [1] https://svnweb.freebsd.org/base/head/usr.bin/wc/wc.c?view=markup#l277 [2] https://svnweb.freebsd.org/base/head/usr.bin/wc/wc.c?view=markup#l290 [3] `man 3 mbrtowc`