[self-interest] Snapshot binary compatibility ?

Harald Gliebe harald at gliebe.de
Mon Jul 1 22:02:53 UTC 2002

> Great! That is much easier than trying to recreate the tutorials inside
> a new empty snapshot. One little difference relative to the Sparc
> version was that all the label morphs showed the '\n' character as a
> little box, while in the Sparc they are invisible.

That is caused by the different X servers, if I redirect the display from
a Sparc VM to a linux box, I also get these boxes, while the other way
round (Linux VM, Sun's X server) everything looks fine.
Don't know what would be the best place to handle the difference.

> Doing diff on the *.self files worked better than I expected. I found
> this change surprising:
> diff -r Self4Linux-0.2.2.src/objects/glue/xlib_glue.cpp
> self4.1.5/glue/xlib_glue.cpp
> 547c547
> <   strncpy(buffer, result, size);
> ---
> >   strncat(buffer, result, size);
This is IMHO a bug in Sun's code that showed up only under linux (probably
due to different malloc implementations). The context of this line is:
  buffer = (char*) malloc(size + 1);
  strncpy(buffer, result, size);
  buffer[size] = '\0';
The original strncat appends result to the newly allocated buffer after the
first '\0', depending on the contents of the malloc'd buffer this may
overwrite arbitrary memory. strncpy just copies the result in the right
place. Since the original code works on Solaris, I assume their malloc will
at least clear the first byte of the returned memory.


More information about the Self-interest mailing list