[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Still problems with boot-floppies



On Mon, Nov 08, 1999 at 01:57:36PM +0100, Martin Schulze wrote:
> Fumitoshi UKAI wrote:
> > At Sat, 6 Nov 1999 23:51:43 +0100,
> > Martin Schulze <joey@finlandia.Infodrom.North.DE> wrote:
> > 
> > > At least one cause of problems is that some tools (like strlen() for
> > > example) are failing on NULL pointers.  It's not that the NULL-string
> > > gets to newt, the system crashes before that.
> > > 
> > > Thus, pointerize must NOT return any NULL pointer or we need to
> > > check for NULL pointers on our own.  This would be silly as it 
> > > would mean that we would have to include all strings in the source
> > > again - one reason why pointerize was inveneted, I guess.
> > 
> > Hmm, I'm afraid that we must maintain translation database, in order to
> > make sure that translation[] is not NULL and to keep out original strings 
> > from source...
> > 
> > > Instead of
> > > 
> > >          msg = (translation[94]);
> > > 
> > > we would have to use
> > > 
> > >          msg = (translation[94])?translation[94]:"The original string";
> > 
> > 
> > Well, how about this patch?
> > 
> > --- pointerize-0.3/src/pointerize.c.orig	Sat Jun 19 19:29:31 1999
> > +++ pointerize-0.3/src/pointerize.c	Sun Nov  7 18:07:04 1999
> > @@ -899,7 +899,9 @@
> >         case token_type_string_literal:
> >  	 if (state == 2)
> >  	 {
> > -	   printf ("("VARNAME"[%d]",getidx(token.string));
> > +	   printf ("("VARNAME"[%d]?"VARNAME"[%d]:%s",
> > +			getidx(token.string),
> > +			getidx(token.string), token.buffer);
> >  	   free (token.buffer);
> >  	   free (token.string);
> >  	 }
> > 
> 
> You're my hero!  I was about to get this done during the next days.
> This fixes the problem, although it's not the proper solution.

Indeed. The problem is that of outdated translations. An outdated .trm file
doesn't have the right number of strings so there may be translation[foo]
pointers pointing to an invalid memory area for some values of foo. But
there's another problem and Fumitoshi's patch doesn't fix that. The
remaining translation[] pointers may point to the wrong translation,
giving wrong messages, even dangerous ones! (think about a "Do you want
to format this partition?" dialog box displaying a "Do you want to mount
this as root?" message).

One quick fix without redesigning pointerize is checking the value
returned by LOAD_TRMFILE and stoping (or loading a "C.trm" messages file)
if our translations file is invalid (outdated or whatever).

The followin patch does that:

--- main.c.orig	Mon Nov  8 15:53:15 1999
+++ main.c	Sun Nov  7 20:05:15 1999
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -265,7 +266,16 @@
     /* Disable kmod during installation to avoid console messages. */
     system("echo \"/bin/true\" > /proc/sys/kernel/modprobe");
 
-    LOAD_TRMFILE("/etc/messages.trm");
+    if((LOAD_TRMFILE("/etc/messages.trm"))==0)
+    {
+    /* Bad messages.trm file (perhaps it's an outdated translation), stop
+     * here or be prepared for segfaults */
+    /* Don't pointerize the following string! It'll be used when we
+     * failed loading the tranlations file */
+	fprintf( stderr, "Error loading /etc/messages.trm\nRebooting in five minutes\n");
+	sleep(300);
+        reboot(RB_AUTOBOOT);
+    }
 
     readcmdline();
 

Of course, the proper fix is adding checks to dbootstrap Makefile to be
sure that there are no invlaid .trm files, probably checking that those
strings that are not translated yet are substituted by the original ones
while building the .trm file.

> If Enrique is listening, please enter strings that weren't found
> in the database to the database and reference to them as usual.

Just to be sure, we are proposing the same thing, aren't we?

	Thanks,
--
Enrique Zanardi					   ezanardi@ull.es


Reply to: