Subject: lmarbles: config file corrupted... Package: lmarbles Version: 1.0.7-1 Severity: normal Tags: patch
Every time I start lmarbles, I get this message in the console: config file '/home/nirgal/.lgames/lmarbles.conf' corrupted... using defaults My preferences such as "fullscreen" are not saved. Looking at the code, the program has two formats for saving the preferences: binary and ascii. We are using ascii. There is a test: that the configuration file size match the binary configuration structure size, and load default settings when it does not. That test should occur only when using binary format, not ascii. -- System Information: Debian Release: 6.0 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores) Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages lmarbles depends on: ii libc6 2.11.2-7 Embedded GNU C Library: Shared lib ii libsdl-mixer1.2 1.2.8-6.3 mixer library for Simple DirectMed ii libsdl1.2debian 1.2.14-6.1 Simple DirectMedia Layer lmarbles recommends no packages. lmarbles suggests no packages. -- no debconf information
Description: config file corrupted when using ASCII format Program should not test configuration file size when using ASCII format Please update this header according to http://dep.debian.net/deps/dep3/ Bug-Debian: http://bugs.debian.org/TODO Forwarded: TODO Author: Nirgal Vourgère <[email protected]> Reviewed-by: TODO Last-Update: 2011-01-15 diff -Naur lmarbles-1.0.7.keep/src/cfg.c lmarbles-1.0.7/src/cfg.c --- lmarbles-1.0.7.keep/src/cfg.c 2004-06-09 14:32:45.000000000 +0200 +++ lmarbles-1.0.7/src/cfg.c 2011-01-15 16:00:14.000000000 +0100 @@ -75,15 +75,9 @@ C_Def(); } else { - stat( c_pth, &dir_stat ); - if ( dir_stat.st_size != sizeof( Cfg ) ) { - fprintf( stderr, "config file '%s' corrupted... using defaults\n", c_pth ); - C_Def(); - } - else - { #ifdef ASCII + /* We are using ascii format for preferences file */ F_GetE(f, str, F_VAL); if (strncmp(str,"ascii",5)) { @@ -111,23 +105,30 @@ } #else - - fread(str, 5, 1, f); - if (!strncmp(str,"ascii",5)) { - - printf("cfg file '%s' in ascii but raw binary data expected; using defaults\n", c_pth); + /* We are using binary format for preferences file */ + stat( c_pth, &dir_stat ); + if ( dir_stat.st_size != sizeof( Cfg ) ) { + fprintf( stderr, "config file '%s' corrupted... using defaults\n", c_pth ); C_Def(); - } else { - fseek(f,SEEK_SET,0); - fread(&cfg, sizeof(Cfg), 1, f); + fread(str, 5, 1, f); + if (!strncmp(str,"ascii",5)) { + + printf("cfg file '%s' in ascii but raw binary data expected; using defaults\n", c_pth); + C_Def(); + + } + else { + + fseek(f,SEEK_SET,0); + fread(&cfg, sizeof(Cfg), 1, f); + + } } - #endif - } fclose(f); }

