Am Freitag, den 12.06.2009, 01:21 +0200 schrieb Felix Zielcke: > Am Donnerstag, den 11.06.2009, 01:00 +0200 schrieb Felix Zielcke: > > Am Dienstag, den 09.06.2009, 23:51 +0200 schrieb Vladimir 'phcoder' > > Serbinenko: > > > > > + > > > +char *grub_make_system_path_relative_to_its_root (char *path) > > > +{ > > > + > > > + struct stat st; > > > + char buf[500], buf2[500]; > > > Use malloc instead of static allocation > > > > Changed. > > > > > + p = strrchr (buf, '/'); > > > + if (p != buf) > > > + *p = 0; > > > + else *++p = 0; > > > You assume path starts with /. You have to check this. Otherwise you > > > may get sigsegv > > > > Changed. > > > + strcpy(buf2,buf); > > > Just save (p - buf) instead of copying buf to buf2 > > > > I did this now if realpath () isn't avaible. > > Now realpath is used in case it's avaible. POSIX specifies it and > > readlink is actually using it if it's avaible. I didn't read the source > > correctly. > > The problem is just Cygwin. It has it but it returns the cygwin path. > > So C:\\Windows would get /cygdrive/c/windows, which is easy to handle. > > But realpath ("/boot/grub") would return /boot/grub which isn't true > > from Windows/GRUB point of view. > > Maybe Christian and Bean can say something about it. > > MingW doestn't have it and I don't know what Windows would have, so the > > MingW users would still use my own way. > > Here's now a new one which aborts if realpath is avaible but doestn't > support (path, NULL) > and the fallback function is changed to dynamically allocate the memory. > And now all memory is properly free'd
args just noticed I forgot the *free_ptr = buf2; I'm too lazy now to send an extra patch just for this. -- Felix Zielcke _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel