lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxIcI0QRFGZLCNRl@mail.google.com>
Date: Fri, 18 Oct 2024 21:28:19 +1300
From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@...il.com>
To: mpe@...erman.id.au, npiggin@...il.com, christophe.leroy@...roup.eu,
	naveen@...nel.org, maddy@...ux.ibm.com, arnd@...db.de,
	chentao@...inos.cn, linuxppc-dev@...ts.ozlabs.org,
	linux-kernel@...r.kernel.org
Cc: paulo.miguel.almeida.rodenas@...il.com, linux-hardening@...r.kernel.com
Subject: [PATCH][next] powerpc/spufs: Replace snprintf() with the safer
 scnprintf() variant

The C99 standard specifies that {v}snprintf() returns the length of the
data that *would have been* written if there were enough space. In some
cases, this misunderstanding led to buffer-overruns in the past. It's
generally considered better/safer to use the {v}scnprintf() variants in
their place.

While at it, fix some style issues pointed out by checkpatch.pl

Link: https://lwn.net/Articles/69419/
Link: https://github.com/KSPP/linux/issues/105
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@...il.com>
---
 arch/powerpc/platforms/cell/spufs/file.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index d5a2c77bc908..f766821fe3bf 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2320,13 +2320,13 @@ static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
 
 	p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE;
 
-	return snprintf(tbuf, n, "%llu.%09u %d %u %u %llu\n",
-			(unsigned long long) p->tstamp.tv_sec,
-			(unsigned int) p->tstamp.tv_nsec,
-			p->spu_id,
-			(unsigned int) p->type,
-			(unsigned int) p->val,
-			(unsigned long long) p->timebase);
+	return scnprintf(tbuf, n, "%llu.%09u %d %u %u %llu\n",
+			 (unsigned long long)p->tstamp.tv_sec,
+			 (unsigned int)p->tstamp.tv_nsec,
+			 p->spu_id,
+			 (unsigned int)p->type,
+			 (unsigned int)p->val,
+			 (unsigned long long)p->timebase);
 }
 
 static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
-- 
2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ