ec03d9af91
Prevent buffer overflow from environment variable; from Debian.
13 lines
795 B
Plaintext
13 lines
795 B
Plaintext
$OpenBSD: patch-src_editor_c,v 1.1 2004/03/02 22:18:53 naddy Exp $
|
|
--- src/editor.c.orig 2002-02-22 12:59:28.000000000 +0100
|
|
+++ src/editor.c 2004-03-02 21:55:07.000000000 +0100
|
|
@@ -725,7 +725,7 @@ int editor_init( char *file_name )
|
|
{
|
|
FILE *file = 0;
|
|
/* set full file name */
|
|
- sprintf( edit_file_name, "%s/%s/lbreakout2-levels/%s", (getenv( "HOME" )?getenv( "HOME" ):"."), CONFIG_DIR_NAME, file_name );
|
|
+ snprintf( edit_file_name, sizeof(edit_file_name), "%s/%s/lbreakout2-levels/%s", (getenv( "HOME" )?getenv( "HOME" ):"."), CONFIG_DIR_NAME, file_name );
|
|
/* test this file for write access. use append to keep contents */
|
|
if ( ( file = fopen( edit_file_name, "a" ) ) == 0 ) {
|
|
fprintf( stderr, "Permission to write to file '%s' denied.\n", edit_file_name );
|