Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3d4b0ab

Browse files
committed
Reject invalid input in int2vectorin.
Since the int2vector type is intended only for internal use, this patch doesn't worry about prettifying the error messages, which has the fringe benefit of avoiding creating additional translatable strings. For a type intended to be used by end-users, we would want to do better, but the approach taken here seems like the correct trade-off for this case. Caleb Welton
1 parent 540e69a commit 3d4b0ab

File tree

1 file changed

+4
-3
lines changed
  • src/backend/utils/adt

1 file changed

+4
-3
lines changed

src/backend/utils/adt/int.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.86 2009/09/04 11:20:22 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.87 2009/12/30 01:29:22 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -146,10 +146,11 @@ int2vectorin(PG_FUNCTION_ARGS)
146146

147147
for (n = 0; *intString && n < FUNC_MAX_ARGS; n++)
148148
{
149-
if (sscanf(intString, "%hd", &result->values[n]) != 1)
150-
break;
151149
while (*intString && isspace((unsigned char) *intString))
152150
intString++;
151+
if (*intString == '\0')
152+
break;
153+
result->values[n] = pg_atoi(intString, sizeof(int16), ' ');
153154
while (*intString && !isspace((unsigned char) *intString))
154155
intString++;
155156
}

0 commit comments

Comments
 (0)