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

perl, C, and odd things



Hi,

I have noticed a strange thing with this piece of code :
A perl program calls this :

   fb_c_stuff::init_effects($FPATH);

with $FPATH = "/usr/share/frozen-bubble"

Here is the corresponding C code :

void plasma_init(char * datapath)
{
        char * finalpath;
        char mypath[] = "/data/plasma.raw";
        FILE * f;
        finalpath = malloc(strlen(datapath) + sizeof(mypath) + 1);
        sprintf(finalpath, "%s%s", datapath, mypath);
        f = fopen(finalpath, "rb");
        free(finalpath);

Then, let's strace the execution. We obtain :
open("/usr/share/frozen-bubble/data/plasma.raw", O_RDONLY|O_LARGEFILE) =
8

Good. But it has been reported that on at least one Debian system (also
an up-to-date sid), it leads to :
open("/usr/share/frozen-bubbledata/plasma.raw", O_RDONLY|O_LARGEFILE) =
-1 ENOENT (No such file or directory)

Looking at the code, I have absolutely no idea of what could remove the
leading '/' in the mypath string. Of course, there is a fix (adding a /
at the end of $FPATH), but it would only hide that something is really
weird here.

Could someone help me ?

Thank you.
-- 
 .''`.           Josselin Mouette        /\./\
: :' :           josselin.mouette@ens-lyon.org
`. `'
  `-  Debian GNU/Linux -- The power of freedom

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: