CVS commit: src/games/morse

2024-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 16 18:09:45 UTC 2024

Modified Files:
src/games/morse: morse.c

Log Message:
games/morse: fix out-of-bounds memory read

Could be triggered by running 'morse äöü', caused by the typical
 usage mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/morse/morse.c
diff -u src/games/morse/morse.c:1.21 src/games/morse/morse.c:1.22
--- src/games/morse/morse.c:1.21	Sun Jun 16 18:00:59 2024
+++ src/games/morse/morse.c	Sun Jun 16 18:09:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: morse.c,v 1.21 2024/06/16 18:00:59 rillig Exp $	*/
+/*	$NetBSD: morse.c,v 1.22 2024/06/16 18:09:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)morse.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: morse.c,v 1.21 2024/06/16 18:00:59 rillig Exp $");
+__RCSID("$NetBSD: morse.c,v 1.22 2024/06/16 18:09:45 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -188,7 +188,7 @@ main(int argc, char **argv)
 		if (*argv)
 			do {
 for (p = *argv; *p; ++p)
-	morse((int)*p);
+	morse((unsigned char)*p);
 show("");
 			} while (*++argv);
 		else while ((ch = getchar()) != EOF)



CVS commit: src/games/morse

2024-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 16 18:09:45 UTC 2024

Modified Files:
src/games/morse: morse.c

Log Message:
games/morse: fix out-of-bounds memory read

Could be triggered by running 'morse äöü', caused by the typical
 usage mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/morse

2024-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 16 18:00:59 UTC 2024

Modified Files:
src/games/morse: morse.c

Log Message:
games/morse: reduce runtime relocations, to save disk space


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/morse/morse.c
diff -u src/games/morse/morse.c:1.20 src/games/morse/morse.c:1.21
--- src/games/morse/morse.c:1.20	Thu Jun  1 04:08:36 2023
+++ src/games/morse/morse.c	Sun Jun 16 18:00:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: morse.c,v 1.20 2023/06/01 04:08:36 mrg Exp $	*/
+/*	$NetBSD: morse.c,v 1.21 2024/06/16 18:00:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)morse.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: morse.c,v 1.20 2023/06/01 04:08:36 mrg Exp $");
+__RCSID("$NetBSD: morse.c,v 1.21 2024/06/16 18:00:59 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -49,8 +49,7 @@ __RCSID("$NetBSD: morse.c,v 1.20 2023/06
 #include 
 #include 
 
-static const char
-	*const digit[] = {
+static const char digit[][6] = {
 	"-",
 	".",
 	"..---",
@@ -61,8 +60,9 @@ static const char
 	"--...",
 	"---..",
 	".",
-},
-	*const alph[] = {
+};
+
+static const char alph[][5] = {
 	".-",
 	"-...",
 	"-.-.",
@@ -93,7 +93,7 @@ static const char
 
 static const struct punc {
 	char c;
-	const char *morse;
+	const char morse[7];
 } other[] = {
 	{ '.', ".-.-.-" },
 	{ ',', "--..--" },
@@ -109,10 +109,9 @@ static const struct punc {
 	{ '+', ".-.-." },
 	{ '_', "..--.-" },
 	{ '@', ".--.-." },
-	{ '\0', NULL }
+	{ '\0', "" }
 };
 
-int	main(int, char *[]);
 static void morse(int);
 static void decode(const char *);
 static void show(const char *);



CVS commit: src/games/morse

2024-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 16 18:00:59 UTC 2024

Modified Files:
src/games/morse: morse.c

Log Message:
games/morse: reduce runtime relocations, to save disk space


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/morse

2023-05-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jun  1 04:08:36 UTC 2023

Modified Files:
src/games/morse: morse.c

Log Message:
add 2004's "@" definition.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/morse

2023-05-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jun  1 04:08:36 UTC 2023

Modified Files:
src/games/morse: morse.c

Log Message:
add 2004's "@" definition.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/games/morse/morse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/morse/morse.c
diff -u src/games/morse/morse.c:1.19 src/games/morse/morse.c:1.20
--- src/games/morse/morse.c:1.19	Sun May  2 12:50:45 2021
+++ src/games/morse/morse.c	Thu Jun  1 04:08:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: morse.c,v 1.19 2021/05/02 12:50:45 rillig Exp $	*/
+/*	$NetBSD: morse.c,v 1.20 2023/06/01 04:08:36 mrg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)morse.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: morse.c,v 1.19 2021/05/02 12:50:45 rillig Exp $");
+__RCSID("$NetBSD: morse.c,v 1.20 2023/06/01 04:08:36 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -108,6 +108,7 @@ static const struct punc {
 	{ '=', "-...-" },
 	{ '+', ".-.-." },
 	{ '_', "..--.-" },
+	{ '@', ".--.-." },
 	{ '\0', NULL }
 };