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

Commitd555d26

Browse files
committed
Fix several one-byte buffer over-reads in to_number
Several places in NUM_numpart_from_char(), which is called from the SQLfunction to_number(text, text), could accidentally read one byte pastthe end of the input buffer (which comes from the input text datum andis not null-terminated).1. One leading space character would be skipped, but there was no check that the input was at least one byte long. This does not happen in practice, but for defensiveness, add a check anyway.2. Commit4a3a1e2 apparently accidentally doubled that code that skips one space character (so that two spaces might be skipped), but there was no overflow check before skipping the second byte. Fix by removing that duplicate code.3. A logic error would allow a one-byte over-read when looking for a trailing sign (S) placeholder.In each case, the extra byte cannot be read out directly, but looking atit might cause a crash.The third item was discovered by Piotr Stefaniak, the first two werefound and analyzed by Tom Lane and Peter Eisentraut.
1 parent5b1da94 commitd555d26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,12 +4119,12 @@ NUM_numpart_from_char(NUMProc *Np, int id, int input_len)
41194119
(id==NUM_0||id==NUM_9) ?"NUM_0/9" :id==NUM_DEC ?"NUM_DEC" :"???");
41204120
#endif
41214121

4122-
if (*Np->inout_p==' ')
4123-
Np->inout_p++;
4124-
41254122
#defineOVERLOAD_TEST(Np->inout_p >= Np->inout + input_len)
41264123
#defineAMOUNT_TEST(_s) (input_len-(Np->inout_p-Np->inout) >= _s)
41274124

4125+
if (OVERLOAD_TEST)
4126+
return;
4127+
41284128
if (*Np->inout_p==' ')
41294129
Np->inout_p++;
41304130

@@ -4274,7 +4274,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int input_len)
42744274
* next char is not digit
42754275
*/
42764276
if (IS_LSIGN(Np->Num)&&isread&&
4277-
(Np->inout_p+1) <=Np->inout+input_len&&
4277+
(Np->inout_p+1)<Np->inout+input_len&&
42784278
!isdigit((unsignedchar)*(Np->inout_p+1)))
42794279
{
42804280
intx;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp