Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4720351ybi; Tue, 30 Jul 2019 07:02:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDII5C7ocPOWiidne/lEfdoR5hUn15DIS+S2SiDabUbRDZ0otk0I3DRXAmF8C2da9a2cqJ X-Received: by 2002:a17:90a:37ac:: with SMTP id v41mr112172249pjb.6.1564495374361; Tue, 30 Jul 2019 07:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564495374; cv=none; d=google.com; s=arc-20160816; b=F+NUf8gKW8/OIHXQr7PwLZRmBJnxWNRXlrqYvoFA+IYDiw9fSkVaOj3MMYKKMIfpKo bN5+WILvPhv+G/XmqNQpYNaAskQc/FmgEFrw6Un6bSE6XJXVLoBt483WZp18OpCNWLsg twToCLG4+uM5SeuGwV10ID1MowaFQ8khXWm2qeiTUPlZB7snAzPJaVOpatkjKkRjN6IR hi2typEur+jjGDQttRUdGn5vQewoP5jAZSAa+37i6yQrvnlBXpVA0K5NFmRlAcEjUw+S DlnBXKPdnabR9t+ZRyrfSxTulit1cxavhyKgfUykEIVQRg41pSHIXUNNRWrrHqzu1zqY 4p+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=89mycYetQz5Yslqgw4Pph6ixeB6FTUjlPdQo+OF5joc=; b=gcb+39CQRNMq9E1KDO5fMoIshK9xCaDlDJZMnIuCyfVQwgkFh4OtJfs1/q2LfzDzwI Q6h8aGaOCrzKsCr3ERX/4kukOsPTJZIZkhaX3h6IhGoUfja1NKdwGOY6FZwaVwn8ll1M uZ17ATRH9RXwxi59G0BCvJIjrl2tUbhnyre0ne7czWiFrBrIdkioECBJnHhDYDZzYCJA 3FYEj20D0fakRa/MHXFjhEMO6VHgXM1j3eNJlh8hnAYKGRCavr2EurjMeQCk4R8z1FGQ HRF1BVHuCbRt661ZbHEHZXIIWuZLNkdV5LEAAkBjccezBNPdYPPd3D8m5Ibh2uEvnk17 4vPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="Knht/IRU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si26228118pgl.398.2019.07.30.07.02.38; Tue, 30 Jul 2019 07:02:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="Knht/IRU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730970AbfG3Ikj (ORCPT + 99 others); Tue, 30 Jul 2019 04:40:39 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43802 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730959AbfG3Ikj (ORCPT ); Tue, 30 Jul 2019 04:40:39 -0400 Received: by mail-pg1-f196.google.com with SMTP id r22so2082691pgk.10 for ; Tue, 30 Jul 2019 01:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=89mycYetQz5Yslqgw4Pph6ixeB6FTUjlPdQo+OF5joc=; b=Knht/IRU4k7wq/cQ51U9Kxl0GUJxlqbKKLjv2bcHydJTmkTGI1lgEFLzf2ku2tIMRe 1WKKDR4H6ZH0aTu5xzGX+lYUbF9om75GP75DYAj+ry99lrHXFWJWxr6MZrp9ppXQZL0h uOiU81fhEolXjHRrU9XkX6YogMjGoMX2b/Gk84URoDW0XFWkHNGvyCoxQoGKNOpsdbKY KfSpp8Q9LSBnJf4MS3Btn/LO+55IxBE/KCEBIbGPHQcVH3SKzA8yAbMNTJF5ZcL3q7vv aykgAf2pBeGUIqa10lPl5i6UmtWtNfUjUFCbBGf+ryV9kturtIUcqPnjXxz8O+dPE/lh njXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=89mycYetQz5Yslqgw4Pph6ixeB6FTUjlPdQo+OF5joc=; b=CZgwIQnZkDK3rk8u10+Ne01rh5y1KMNTk9R2gaB4ou74joAXSJiXur+EN4AQUVerKs hH1huFcCYZVOMxJTG75blwSB5TJA1Op9oxXAzpxCmE8JCcuuu0eviB8hetIWJYIzwcgO 0mh5UZCFQD28pAw6unywovT7iQ5AFBGxh9GFevUKDnu5nvlnVNIGcvzodW28bUpOF9g3 vavdFmatEQctQQKYSHigBGzkzR7KMBVvYs2kcjTWsbBAfkW75GcHIZL96daJetsDYWzo Ian16AHNDot2K+x0WrXRP3/Xuc/a1IdRsWrVlicqC/S2lPBtS8zbK9VOVrCRDUqPilXG zRlg== X-Gm-Message-State: APjAAAXPyBALYByaUEDGHoy/QzVoweXspuT9p02M6gWrEC6ZMKxuAX7T Gc/X/zUCEjGsyl+MRspS4Dg= X-Received: by 2002:a17:90a:9a83:: with SMTP id e3mr113839937pjp.105.1564476038528; Tue, 30 Jul 2019 01:40:38 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id f14sm64869091pfn.53.2019.07.30.01.40.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 01:40:37 -0700 (PDT) From: Chuhong Yuan Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH] drm/modes: Fix unterminated strncpy Date: Tue, 30 Jul 2019 16:40:32 +0800 Message-Id: <20190730084032.26428-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strncpy(dest, src, strlen(src)) leads to unterminated dest, which is dangerous. Fix it by using strscpy. Signed-off-by: Chuhong Yuan --- drivers/gpu/drm/drm_modes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 80fcd5dc1558..170fc24e0f31 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1770,7 +1770,7 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, } if (named_mode) { - strncpy(mode->name, name, mode_end); + strscpy(mode->name, name, mode_end + 1); } else { ret = drm_mode_parse_cmdline_res_mode(name, mode_end, parse_extras, -- 2.20.1