From owner-svn-src-all@freebsd.org Sat Jan 27 22:42:39 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF57DEC7968 for ; Sat, 27 Jan 2018 22:42:38 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-lf0-x22c.google.com (mail-lf0-x22c.google.com [IPv6:2a00:1450:4010:c07::22c]) (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 4329A7D75A for ; Sat, 27 Jan 2018 22:42:38 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-lf0-x22c.google.com with SMTP id v188so4886443lfa.11 for ; Sat, 27 Jan 2018 14:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1KSkqbk9apJLQ4Or3dl2xr4mI4vErXFCix5wB3fZIzU=; b=iUiWRIFHbrqkeu70rlcGiuJOljrQ3v1AqUz6mrO6DJZef0H6GWNrPpTs9WnSmlRjpE xbKL2A5r+0ZxxT+cZh6KayNWa8igTKQ9YJ3Ldb7A2pN6HrAU77E3jqtX+2Nx/AstxNbK v8cixJlE7PeYtAM5uDg3ihgoUeSky1geJfJovif295rcKPL/G/XSRc1SWMbYKGJZsUTf 2uPQLPOc2j5MIlTN+h6P+V1T2WE4m1Kt6TXD8CDQN7MTNNj8jZ8eDLhf/Hi11SMhrudT SKp4H+WgosjLVtA/Fm4nwtYPoAQ77rBMXOGC0aLYkdrodF+QH8hjnGfO4CFmxYl6XSf4 rKNw== 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:cc; bh=1KSkqbk9apJLQ4Or3dl2xr4mI4vErXFCix5wB3fZIzU=; b=JDMvIQ85CknBpsH9EJRJXsoDmEOCs68cNxf3sJBsf6kxundn/Bc9hWSYmKL/iq6Oze qybJCGa3jWb9+/oIuzdXJmuUS7sKJgFX6UHYU+Fw+UEEg32IjZE+b9UhtndTt5Nz7lNU QjobluSUJgzp3PreWRN5dmYYVtjpQ9hLOmV8k0mrGIrrnfHSxWenKOLmgMpUgcVHrx8h 1pth8bqbWYW6y44nFcixk73b6MUT/6JDn0C1RUYE1g0u5HHl1yJWvdP613sIfkBosau2 0nKpgsP6n+cWae8V+MR2vd7YK5jNaYnVoLvIKTfbdTKu0GBrH2BRFqONb0kVEGpAPxmH MCwQ== X-Gm-Message-State: AKwxytcVxZDDga6fDGtkR4HhlIwHoJncHD3OrTw3gFpX3ZD8fMtoIQds uaxlwDhz5ee9zIIbcf96vOiFBE53XHf5vPBW4+Vpig== X-Google-Smtp-Source: AH8x2259x3UvrG0Gz4in+zP/MtexSPkgVXIafi9akU11+RO1UtDqBB2po/6VLThGhqZb1s7KtgSXIlOJYXYRvC0z0BA= X-Received: by 10.46.80.79 with SMTP id v15mr10080858ljd.125.1517092957011; Sat, 27 Jan 2018 14:42:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.216.206 with HTTP; Sat, 27 Jan 2018 14:42:06 -0800 (PST) In-Reply-To: <7C471160-44B3-4EA6-8995-08A4EB4332A1@FreeBSD.org> References: <201801272216.w0RMGJwo057492@repo.freebsd.org> <7C471160-44B3-4EA6-8995-08A4EB4332A1@FreeBSD.org> From: Ed Schouten Date: Sat, 27 Jan 2018 23:42:06 +0100 Message-ID: Subject: Re: svn commit: r328492 - head/contrib/opie/libopie To: Dimitry Andric Cc: "Pedro F. Giffuni" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jan 2018 22:42:39 -0000 2018-01-27 23:31 GMT+01:00 Dimitry Andric : > On 27 Jan 2018, at 23:20, Ed Schouten wrote: >> >> 2018-01-27 23:16 GMT+01:00 Pedro F. Giffuni : >>> char host[sizeof(utmp.ut_host) + 1]; >>> insecure = 1; >>> >>> - strncpy(host, utmp.ut_host, sizeof(utmp.ut_host)); >>> - host[sizeof(utmp.ut_host)] = 0; >>> + strncpy(host, utmp.ut_host, sizeof(host)); >> >> Wait... This may access utmp.ut_host one byte past the end and no >> longer guarantees that host is null-terminated, right? > > No, strncpy "copies at most len characters from src into dst". Substituting 'len', 'src' and 'dst' gives me: strncpy "copies at most 'sizeof(utmp.ut_host) + 1' characters from 'utmp.ut_host' into 'host'". As 'utmp.ut_host' is not guaranteed to be null-terminated by POSIX*, it can actually end up in the situation where it copies 'sizeof(utmp.ut_host) + 1' characters, which may leave 'host' unterminated. -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands