From patchwork Tue Nov 3 16:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1393197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=RS+wwEfj; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CQb3k4cMZz9sTD for ; Wed, 4 Nov 2020 03:34:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACF133854831; Tue, 3 Nov 2020 16:34:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 62AB03854827 for ; Tue, 3 Nov 2020 16:34:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 62AB03854827 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x731.google.com with SMTP id o205so8421064qke.10 for ; Tue, 03 Nov 2020 08:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=wsAcKl2+gum62r9Uhx3dS/4EOIl25jW6QlKs+9lY/84=; b=RS+wwEfj+qkBgpUaUJ16j1YI3zBjAngNgwqxc2aXgddFy9U4v8vf5oroO7RkDOsHv5 JBVvtUezNmK0zzVkkujNWnhtGxnic2j/SOtnG3QNVmpnI9sAiRVzR8GOAwnCqm1BksMi 9sTmvHiyQyGUaU5l9L5hSsAtngwRhC9/78SgCc6OAeqdWnnTlBIMAWHcL23b/dRy+MBi LWzje1ZnIylVj0d81yB/6UWoARVmn3Wjgh4UfKVWA1tzGYAXG6BgfqLsSWKPhax0gyIO 6OyazxIh011TX6+u+MNQ1dNrYBxdIz+3EduQP6ugpICmYG98OCOF8Nz3nx/P+IywP8qR jN+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=wsAcKl2+gum62r9Uhx3dS/4EOIl25jW6QlKs+9lY/84=; b=Hkin8TLDz0MVGkEtmJXLunY8NVTiMmUuqdDIuweMMDr2b2oDy1n2KhqPM1Xa56EQfo L6DDehUTm/8/x/XZP7f92NQqjFArD/5YW6ZgUMvDLFZ6ImqsZnbK7pYhnTDzOV6JgD90 dJxKzChSd8PqDlwHLQzx5yfWe4VdctkFRDFzxJhmbQEzcG75kVbx2ud6TEIT9m8F7vtP WyCYRHfu/OvXdySCdOJZjVbGf/rvQpH795KZaFcuP6fWRtrLmh6U2V8EMd28/GC9+Y2c RyNuS354lhqdwl0HAo8V6YEscW3ifJFi+FBTsMTedASISIdpRlhE6sgvusETGG6ySqpf /AVw== X-Gm-Message-State: AOAM533afNGceM5inlqIIyeDf0+B/H5pE2XfKOGhB7n+nINuaCl0GJ6G hYa/1TwyqQw4kCjagLblddU= X-Google-Smtp-Source: ABdhPJxkWOkD/10DMTwtqp559S37UCcEg1IQvxDqnV7851JpTdmNQ2n6qsyb3EZtEn/wcPq3bi8Vfw== X-Received: by 2002:ae9:e60c:: with SMTP id z12mr20393104qkf.392.1604421291514; Tue, 03 Nov 2020 08:34:51 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:e5ef:7eb4:1609:98bb? ([2620:10d:c091:480::1:bc2d]) by smtp.googlemail.com with ESMTPSA id d18sm8865163qka.41.2020.11.03.08.34.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Nov 2020 08:34:50 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: cpplib: Fix off-by-one error Message-ID: <7d85ffb2-e00f-1496-0d84-559231fa4a5a@acm.org> Date: Tue, 3 Nov 2020 11:34:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" I noticed a fencepost error in the preprocessor. We should be checking if the next char is at the limit, not the current char (which can't be, because we're looking at it). libcpp/ * lex.c (_cpp_clean_line): Fix DOS off-by-one error. pushing to trunk diff --git i/libcpp/lex.c w/libcpp/lex.c index fb222924c8c..1d522030a3c 100644 --- i/libcpp/lex.c +++ w/libcpp/lex.c @@ -1062,7 +1062,7 @@ _cpp_clean_line (cpp_reader *pfile) d = (uchar *) s; /* Handle DOS line endings. */ - if (*s == '\r' && s != buffer->rlimit && s[1] == '\n') + if (*s == '\r' && s + 1 != buffer->rlimit && s[1] == '\n') s++; }