From: <er...@he...> - 2004-08-11 15:46:15
|
On Tue, Aug 10, 2004 at 03:26:37PM -0600, Michal Jaegermann wrote: > > There is a bug in a function show_deps(), modhelper.c, from > beoboot-cm1.9. The code goes like that: > > while (p && *p) { > np = strchr(p, ','); > printf("%.*s", np-p, p) > > If there is no comma in a string p then np is set to NULL and > np-p may overflow the second argument to printf which happens to > be int. When this happens, which is pretty likely on 64-bit platforms, > then printf errors out, returns a negaive value and nothing is printed. > If you wonder I got hit by that. :-) On x86 you may usually get > away with this. > > Here is a fix: > > --- beoboot-cm1.9/modhelper.c~ 2004-04-19 11:07:31.000000000 -0600 > +++ beoboot-cm1.9/modhelper.c 2004-08-10 15:00:13.377034440 -0600 > @@ -236,11 +236,13 @@ > p = deps; > while (p && *p) { > np = strchr(p, ','); > - printf("%.*s", np-p, p); > - if (np) { > - printf(" "); > + if (np != NULL) { > + printf("%.*s ", (int)(np-p), p); > np++; > } > + else { > + printf("%s", p); > + } > p = np; > } > printf("\n"); > > OTOH 'modhelper -d' is used in /usr/bin/beoboot script only in > this function: > > module_dep() { > local MODDIR="$1" > local MOD="$2" > local DEPS= > local dep > DEPS=`module_expand $MODDIR \`$BEOLIB/bin/modhelper -d "$MOD"\`` > for dep in $DEPS; do > echo "$dep" > module_dep "$MODDIR" "$dep" > done > } > > which could be simply rewritten as > > module_dep() { > [ -r "$1/modules.dep" ] || depmod > sed -n 's!'"$2"': *!!p' "$1/modules.dep" > } > > making all this recursion unnecessary (and skirting the bug in the > process). Sounds good to me. I'll take the simple road. I think modhelper started life as a prototype for the module loading code in the boot program. I'm glad they got rid of those @#!$ stupid newline escapes in modules.dep. - Erik |