Skip to content

Commit 9f7c4e0

Browse files
author
holzboote@googlemail.com
committed
Fix for CONC-92:
Since NULL values in a binary result packet are represented in a bitmap, the packet length might be smaller than the number of result set NULL values, so we need to allocate additional bytes (=Number of fields) to prevent a possible memory corruption
1 parent 6aea5be commit 9f7c4e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libmariadb/libmariadb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
11941194
sizeof(MYSQL_ROWS))) ||
11951195
!(cur->data= ((MYSQL_ROW)
11961196
alloc_root(&result->alloc,
1197-
(fields+1)*sizeof(char *)+pkt_len))))
1197+
(fields+1)*sizeof(char *)+fields+pkt_len))))
11981198
{
11991199
free_rows(result);
12001200
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0);
@@ -1203,7 +1203,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
12031203
*prev_ptr=cur;
12041204
prev_ptr= &cur->next;
12051205
to= (char*) (cur->data+fields+1);
1206-
end_to=to+pkt_len-1;
1206+
end_to=to+fields+pkt_len-1;
12071207
for (field=0 ; field < fields ; field++)
12081208
{
12091209
if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH)

0 commit comments

Comments
 (0)