Issue information

Issue ID
#1939
Status
Fixed
Severity
Medium
Started
Hercules Elf Bot
Jul 29, 2008 1:01
Last Post
Hercules Elf Bot
Jul 29, 2008 1:01
Confirmation
Yes (1)
No (0)

Hercules Elf Bot - Jul 29, 2008 1:01

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

The sql mapreg loading code apparently suffers from an off-by-one mistake:
CODE
[Debug]: at g:\meinserver (server)\src\common\sql.c:513 - SELECT `varname`, `index`, `value` FROM `mapreg`
[SQL]: DB error - data of field 'value' was truncated.
[Debug]: column - 2
[Debug]: data   - type=MYSQL_TYPE_VAR_STRING, length=255
[Debug]: buffer - type=MYSQL_TYPE_STRING, length=254+1(nul-terminator)

the related code is
CODE
    char varname[32+1];
    char value[255+1];

    SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], 32, &length, NULL);
    SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], 255, NULL, NULL);
it is possible that bindcolumn needs the array with with the zero terminator included?