From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753190AbbJTUan (ORCPT ); Tue, 20 Oct 2015 16:30:43 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:33727 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753116AbbJTUai (ORCPT ); Tue, 20 Oct 2015 16:30:38 -0400 From: Rasmus Villemoes To: Andrew Morton Cc: Rasmus Villemoes , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH 09/13] lib/test_printf.c: add a few string tests Date: Tue, 20 Oct 2015 22:30:09 +0200 Message-Id: <1445373013-20207-10-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1445373013-20207-1-git-send-email-linux@rasmusvillemoes.dk> References: <1445373013-20207-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc: Kees Cook Signed-off-by: Rasmus Villemoes --- lib/test_printf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/test_printf.c b/lib/test_printf.c index 1ce1a1dd8faf..80ddafb2675d 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -166,6 +166,10 @@ test_string(void) test("", "%s%.0s", "", "123"); test("ABCD|abc|123", "%s|%.3s|%.*s", "ABCD", "abcdef", 3, "123456"); test("1 | 2|3 | 4|5 ", "%-3s|%3s|%-*s|%*s|%*s", "1", "2", 3, "3", 3, "4", -3, "5"); + test("1234 ", "%-10.4s", "123456"); + test(" 1234", "%10.4s", "123456"); + /* Negative precision should be treated as 0. */ + test(" ", "%4.*s", -5, "123456"); /* * POSIX and C99 say that a missing precision should be * treated as a precision of 0. However, the kernel's printf -- 2.6.1