Issue information

Issue ID
#2860
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Mar 13, 2009 3:37
Last Post
Hercules Elf Bot
Mar 13, 2009 3:37
Confirmation
N/A

Hercules Elf Bot - Mar 13, 2009 3:37

Originally posted by [b]Ai4rei[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2860

Variable path is used in the column storage error before it gets filled by snprintf resulting in ShowError printing out junk data.

src/common/strlib.c:
CODE
bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current))
{
    FILE* fp;
    int lines = 0;
    int entries = 0;
    char* fields[64]; // room for 63 fields ([0] is reserved)
    int columns;
    char path[1024], line[1024];

+    snprintf(path, sizeof(path), "%s/%s", directory, filename);
    if( maxcols > ARRAYLENGTH(fields)-1 )
    {
        ShowError("sv_readdb: Insufficient column storage in parser for file \"%s\" (want %d, have only %d). Increase the capacity in the source code please.\n", path, maxcols, ARRAYLENGTH(fields)-1);
        return false;
    }

    // open file
-    snprintf(path, sizeof(path), "%s/%s", directory, filename);
    fp = fopen(path, "r");
    if( fp == NULL )
    {
        ShowError("sv_readdb: can't read %s\n", path);
        return false;
    }


This post has been edited by Ai4rei: Mar 12 2009, 08:38 PM