Commit fbfe6b67 authored by unknown's avatar unknown

ft_nlq_search.c:

  Added bounds check to avoid accessing unallocated FT_DOC array.  (BUG #8522)


myisam/ft_nlq_search.c:
  Added bounds check to avoid accessing unallocated FT_DOC array.  (BUG #8522)
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 64bd892d
...@@ -24,6 +24,7 @@ bk@admin.bk ...@@ -24,6 +24,7 @@ bk@admin.bk
brian@brian-akers-computer.local brian@brian-akers-computer.local
carsten@tsort.bitbybit.dk carsten@tsort.bitbybit.dk
davida@isil.mysql.com davida@isil.mysql.com
dean@mysql.com
dellis@goetia.(none) dellis@goetia.(none)
dlenev@brandersnatch.localdomain dlenev@brandersnatch.localdomain
dlenev@build.mysql.com dlenev@build.mysql.com
......
...@@ -205,6 +205,10 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, ...@@ -205,6 +205,10 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query,
left_root_right)) left_root_right))
goto err2; goto err2;
/*
If ndocs == 0, this will not allocate RAM for FT_INFO.doc[],
so if ndocs == 0, FT_INFO.doc[] must not be accessed.
*/
dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+ dlist=(FT_INFO *)my_malloc(sizeof(FT_INFO)+
sizeof(FT_DOC)*(aio.dtree.elements_in_tree-1), sizeof(FT_DOC)*(aio.dtree.elements_in_tree-1),
MYF(0)); MYF(0));
...@@ -275,7 +279,8 @@ float ft_nlq_find_relevance(FT_INFO *handler, ...@@ -275,7 +279,8 @@ float ft_nlq_find_relevance(FT_INFO *handler,
else else
a=c; a=c;
} }
if (docs[a].dpos == docid) /* bounds check to avoid accessing unallocated handler->doc */
if (a < handler->ndocs && docs[a].dpos == docid)
return (float) docs[a].weight; return (float) docs[a].weight;
else else
return 0.0; return 0.0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment