Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f442cb

Browse files
committed
Correct unsafe use of strcmp(). See rant of same date posted to pghackers.
1 parentf0b4ae6 commit9f442cb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* out of its tuple
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.56 2000/07/0605:48:11 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.57 2000/07/0623:03:37 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -818,7 +818,8 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
818818

819819
query= (Query*)lfirst(actions);
820820

821-
if (ev_type!='1'||ev_attr >=0|| !is_instead||strcmp(ev_qual,"<>"))
821+
if (ev_type!='1'||ev_attr >=0|| !is_instead||
822+
strcmp(ev_qual,"<>")!=0)
822823
{
823824
appendStringInfo(buf,"Not a view");
824825
return;
@@ -929,9 +930,9 @@ get_select_query_def(Query *query, deparse_context *context)
929930
rte= (RangeTblEntry*)lfirst(l);
930931
if (rte->ref==NULL)
931932
continue;
932-
if (!strcmp(rte->ref->relname,"*NEW*"))
933+
if (strcmp(rte->ref->relname,"*NEW*")==0)
933934
continue;
934-
if (!strcmp(rte->ref->relname,"*OLD*"))
935+
if (strcmp(rte->ref->relname,"*OLD*")==0)
935936
continue;
936937

937938
rt_constonly= FALSE;
@@ -948,7 +949,7 @@ get_select_query_def(Query *query, deparse_context *context)
948949
sep=" ";
949950
foreach(l,query->targetList)
950951
{
951-
booltell_as=FALSE;
952+
booltell_as=false;
952953

953954
tle= (TargetEntry*)lfirst(l);
954955
appendStringInfo(buf,sep);
@@ -959,16 +960,15 @@ get_select_query_def(Query *query, deparse_context *context)
959960

960961
/* Check if we must say AS ... */
961962
if (!IsA(tle->expr,Var))
962-
tell_as=strcmp(tle->resdom->resname,"?column?");
963+
tell_as=(strcmp(tle->resdom->resname,"?column?")!=0);
963964
else
964965
{
965966
Var*var= (Var*) (tle->expr);
966967
char*attname;
967968

968969
rte=get_rte_for_var(var,context);
969970
attname=get_attribute_name(rte->relid,var->varattno);
970-
if (strcmp(attname,tle->resdom->resname))
971-
tell_as= TRUE;
971+
tell_as= (strcmp(attname,tle->resdom->resname)!=0);
972972
}
973973

974974
/* and do if so */
@@ -990,9 +990,9 @@ get_select_query_def(Query *query, deparse_context *context)
990990

991991
if (rte->ref==NULL)
992992
continue;
993-
if (!strcmp(rte->ref->relname,"*NEW*"))
993+
if (strcmp(rte->ref->relname,"*NEW*")==0)
994994
continue;
995-
if (!strcmp(rte->ref->relname,"*OLD*"))
995+
if (strcmp(rte->ref->relname,"*OLD*")==0)
996996
continue;
997997

998998
appendStringInfo(buf,sep);
@@ -1107,9 +1107,9 @@ get_insert_query_def(Query *query, deparse_context *context)
11071107
rte= (RangeTblEntry*)lfirst(l);
11081108
if (rte->ref==NULL)
11091109
continue;
1110-
if (!strcmp(rte->ref->relname,"*NEW*"))
1110+
if (strcmp(rte->ref->relname,"*NEW*")==0)
11111111
continue;
1112-
if (!strcmp(rte->ref->relname,"*OLD*"))
1112+
if (strcmp(rte->ref->relname,"*OLD*")==0)
11131113
continue;
11141114

11151115
rt_constonly= FALSE;
@@ -1280,9 +1280,9 @@ get_rule_expr(Node *node, deparse_context *context)
12801280
if (rte->ref==NULL)
12811281
appendStringInfo(buf,"%s.",
12821282
quote_identifier(rte->relname));
1283-
elseif (!strcmp(rte->ref->relname,"*NEW*"))
1283+
elseif (strcmp(rte->ref->relname,"*NEW*")==0)
12841284
appendStringInfo(buf,"new.");
1285-
elseif (!strcmp(rte->ref->relname,"*OLD*"))
1285+
elseif (strcmp(rte->ref->relname,"*OLD*")==0)
12861286
appendStringInfo(buf,"old.");
12871287
else
12881288
appendStringInfo(buf,"%s.",
@@ -1520,14 +1520,14 @@ get_func_expr(Expr *expr, deparse_context *context)
15201520
*/
15211521
if (procStruct->pronargs==1&&procStruct->proargtypes[0]==InvalidOid)
15221522
{
1523-
if (!strcmp(proname,"nullvalue"))
1523+
if (strcmp(proname,"nullvalue")==0)
15241524
{
15251525
appendStringInfoChar(buf,'(');
15261526
get_rule_expr((Node*)lfirst(expr->args),context);
15271527
appendStringInfo(buf," ISNULL)");
15281528
return;
15291529
}
1530-
if (!strcmp(proname,"nonnullvalue"))
1530+
if (strcmp(proname,"nonnullvalue")==0)
15311531
{
15321532
appendStringInfoChar(buf,'(');
15331533
get_rule_expr((Node*)lfirst(expr->args),context);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp