Module Name: src
Committed By: leot
Date: Sat May 26 11:20:31 UTC 2018
Modified Files:
src/usr.bin/tr: str.c
Log Message:
Do not accept invalid octal character values (>= 0400).
This also avoid possible stack corruption (e.g. previously `tr -s '\400'' or
similars lead to them).
Reviewed and thanks to <pgoyette>!
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/tr/str.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/tr/str.c
diff -u src/usr.bin/tr/str.c:1.29 src/usr.bin/tr/str.c:1.30
--- src/usr.bin/tr/str.c:1.29 Sun Aug 11 01:54:35 2013
+++ src/usr.bin/tr/str.c Sat May 26 11:20:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.29 2013/08/11 01:54:35 dholland Exp $ */
+/* $NetBSD: str.c,v 1.30 2018/05/26 11:20:30 leot Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)str.c 8.2 (Berkeley) 4/28/95";
#endif
-__RCSID("$NetBSD: str.c,v 1.29 2013/08/11 01:54:35 dholland Exp $");
+__RCSID("$NetBSD: str.c,v 1.30 2018/05/26 11:20:30 leot Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -417,6 +417,8 @@ backslash(STR *s)
}
if (cnt) {
/* We saw digits, so return their value */
+ if (val >= OOBCH)
+ errx(1, "Invalid octal character value");
return val;
}
if (ch == '\0') {