From 4af6ccb13c0b15884de7ae705671083a7b06d335 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 1 Apr 2021 14:27:47 +0000 Subject: [PATCH] For the snprintf range check demo, add a (size_t) cast in the right place which will satisfy the toughest compiler options --- lib/libc/stdio/printf.3 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3 index 7c0759b7aad..f83b9030fc0 100644 --- a/lib/libc/stdio/printf.3 +++ b/lib/libc/stdio/printf.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: printf.3,v 1.89 2020/09/13 12:58:08 tb Exp $ +.\" $OpenBSD: printf.3,v 1.90 2021/04/01 14:27:47 deraadt Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ .\" .\" @(#)printf.3 8.1 (Berkeley) 6/4/93 .\" -.Dd $Mdocdate: September 13 2020 $ +.Dd $Mdocdate: April 1 2021 $ .Dt PRINTF 3 .Os .Sh NAME @@ -1019,7 +1019,7 @@ for later interpolation by Be sure to use the proper secure idiom: .Bd -literal -offset indent int ret = snprintf(buffer, sizeof(buffer), "%s", string); -if (ret < 0 || ret >= sizeof(buffer)) +if (ret < 0 || (size_t)ret >= sizeof(buffer)) goto toolong; .Ed .Pp -- 2.20.1