[HELP] Server crash on linux
#2

If you use io_read and the file doesn't exist, the server will crash.

Add a check to confirm the file you're trying to open with fopen()'s io_read parameters actually exists.

Not sure if this crash is exclusive to Linux.

pawn Code:
stock fdeleteline(filename[], removed[])
{
    new string[64], str[32], File:handle, File:ftmp;
    if(fexist(filename)) handle = fopen(filename,io_read); else return 0;
    format(str,sizeof(str),"%s.part",filename);
    if(fexist(str)) ftmp = fopen(str,io_write); else return 0;
    while(fread(handle,string))
        if(strfind(string,removed) == -1)
            fwrite(ftmp,string);
    fclose(handle);
    fclose(ftmp);
    handle = fopen(filename,io_write);
    if(fexist(str)) ftmp = fopen(str,io_read); else return 0;
    while(fread(ftmp,string))
        fwrite(handle,string);
    fclose(handle);
    fclose(ftmp);
    return fremove(str);
}
Reply


Messages In This Thread
[HELP] Server crash on linux - by telmo_ferreira - 16.11.2011, 22:37
Re: [HELP] Server crash on linux - by Calgon - 17.11.2011, 03:13
Re: [HELP] Server crash on linux - by MP2 - 17.11.2011, 07:02
Re: [HELP] Server crash on linux - by telmo_ferreira - 17.11.2011, 12:45
Re: [HELP] Server crash on linux - by telmo_ferreira - 17.11.2011, 14:19
Re: [HELP] Server crash on linux - by teste - 06.12.2011, 18:38

Forum Jump:


Users browsing this thread: 1 Guest(s)