Skip to content

Commit

Permalink
Bug#27799513: POTENTIAL DOUBLE FREE OR CORRUPTION OF HEAP
Browse files Browse the repository at this point in the history
              INFO (HP_INFO)

Description:- Server crashes due to memory overflow.

Analysis:- Bytes for storing key length is wrongly set
for HEAP tables.

Fix:- Bytes used to store the key length is properly set
inside "heap_create()".
  • Loading branch information
Arun Kuruvila committed Jun 29, 2018
1 parent e1fdeb2 commit 22e99fc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions storage/heap/hp_create.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -92,7 +92,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
/* fall_through */
case HA_KEYTYPE_VARTEXT1:
keyinfo->flag|= HA_VAR_LENGTH_KEY;
length+= 2;
/*
For BTREE algorithm, key length, greater than or equal
to 255, is packed on 3 bytes.
*/
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
length+= size_to_store_key_length(keyinfo->seg[j].length);
else
length+= 2;
/* Save number of bytes used to store length */
keyinfo->seg[j].bit_start= 1;
break;
Expand All @@ -101,7 +108,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
/* fall_through */
case HA_KEYTYPE_VARTEXT2:
keyinfo->flag|= HA_VAR_LENGTH_KEY;
length+= 2;
/*
For BTREE algorithm, key length, greater than or equal
to 255, is packed on 3 bytes.
*/
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
length+= size_to_store_key_length(keyinfo->seg[j].length);
else
length+= 2;
/* Save number of bytes used to store length */
keyinfo->seg[j].bit_start= 2;
/*
Expand Down

0 comments on commit 22e99fc

Please sign in to comment.