Skip to content

Commit b8b5801

Browse files
committed
to_char(): prevent accesses beyond the allocated buffer
Previously very long field masks for floats could access memory beyond the existing buffer allocated to hold the result. Reported by Andres Freund and Peter Geoghegan. Backpatch to all supported versions. Security: CVE-2015-0241
1 parent fa06ce5 commit b8b5801

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4416,7 +4416,9 @@ NUM_numpart_to_char(NUMProc *Np, int id)
44164416
Np->num_in = TRUE;
44174417
}
44184418
}
4419-
++Np->number_p;
4419+
/* do no exceed string length */
4420+
if (*Np->number_p)
4421+
++Np->number_p;
44204422
}
44214423

44224424
end = Np->num_count + (Np->out_pre_spaces ? 1 : 0) + (IS_DECIMAL(Np->Num) ? 1 : 0);

0 commit comments

Comments
 (0)