From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1211) id C54053858C2C; Sat, 8 Apr 2023 20:54:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C54053858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680987244; bh=hv1KaCItjBwz5mJixkcK8QvKL5CdTL9+I38w8EWWLbI=; h=From:To:Subject:Date:From; b=EDuEJNhhOw7mpcvraRnR5sjn1RHsibbJj9u8Fiz1HmSnCMaNXrV68Zo8j5S061Umo eev3BUrzPx2XWuoJr9ujjkwAcvRTjZJ8Pm1T2em4G2wG7/k+UP6sGmLEb01XdVtcWr JQAwFNqsD76x8rSk7eC5y2Mb8Q5lxR8jYqi4oRh4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Paul Eggert To: glibc-cvs@sourceware.org Subject: [glibc] manual: document snprintf truncation better X-Act-Checkin: glibc X-Git-Author: Paul Eggert X-Git-Refname: refs/heads/master X-Git-Oldrev: 1fb225923a1da5dd54d4e7460ccb7fcd12879982 X-Git-Newrev: f173e27272e6e37cab016f9ef3f90d3e1189329f Message-Id: <20230408205404.C54053858C2C@sourceware.org> Date: Sat, 8 Apr 2023 20:54:04 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f173e27272e6e37cab016f9ef3f90d3e1189329f commit f173e27272e6e37cab016f9ef3f90d3e1189329f Author: Paul Eggert Date: Sat Apr 8 13:51:26 2023 -0700 manual: document snprintf truncation better Diff: --- manual/stdio.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manual/stdio.texi b/manual/stdio.texi index c502a21036..3820a24f3e 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -2439,7 +2439,10 @@ If @var{size} is zero, nothing, not even the null byte, shall be written and The return value is the number of characters which would be generated for the given input, excluding the trailing null. If this value is greater than or equal to @var{size}, not all characters from the result have -been stored in @var{s}. You should try again with a bigger output +been stored in @var{s}. If this happens, you should be wary of using +the truncated result as that could lead to security, encoding, or +other bugs in your program (@pxref{Truncating Strings}). +Instead, you should try again with a bigger output string. Here is an example of doing this: @smallexample