Skip to content

Commit 532a4c3

Browse files
committed
Be a little more careful with the shift computations in QT2QTN and
makeTSQuerySign. The first of these is a live bug, on some platforms, as per bug #5590 from John Regehr. However the consequences seem limited because of the relatively narrow scope of use of QTNode.sign. The shift in makeTSQuerySign is actually safe because TSQS_SIGLEN is unsigned, but it seems like a good idea to insert an explicit cast rather than depend on that.
1 parent 57641a1 commit 532a4c3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/backend/utils/adt/tsquery_op.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.9 2010/08/03 00:10:39 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.10 2010/08/03 01:50:26 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -209,7 +209,7 @@ makeTSQuerySign(TSQuery a)
209209
for (i = 0; i < a->size; i++)
210210
{
211211
if (ptr->type == QI_VAL)
212-
sign |= ((TSQuerySign) 1) << (ptr->qoperand.valcrc % TSQS_SIGLEN);
212+
sign |= ((TSQuerySign) 1) << (((unsigned int) ptr->qoperand.valcrc) % TSQS_SIGLEN);
213213
ptr++;
214214
}
215215

src/backend/utils/adt/tsquery_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.14 2010/08/03 00:10:39 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.15 2010/08/03 01:50:27 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -45,7 +45,7 @@ QT2QTN(QueryItem *in, char *operand)
4545
else if (operand)
4646
{
4747
node->word = operand + in->qoperand.distance;
48-
node->sign = 1 << (in->qoperand.valcrc % 32);
48+
node->sign = ((uint32) 1) << (((unsigned int) in->qoperand.valcrc) % 32);
4949
}
5050

5151
return node;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy