Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4032ef1

Browse files
author
Michael Meskes
committed
Fix buffer overflow on particularly named files and clarify documentation about
output file naming. Patch by Tsunakawa, Takayuki <[email protected]>
1 parent ea0aa96 commit 4032ef1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

doc/src/sgml/ref/ecpg-ref.sgml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ PostgreSQL documentation
4242
<para>
4343
<command>ecpg</command> will convert each input file given on the
4444
command line to the corresponding C output file. Input files
45-
preferably have the extension <filename>.pgc</filename>, in which
46-
case the extension will be replaced by <filename>.c</filename> to
47-
determine the output file name. If the extension of the input file
48-
is not <filename>.pgc</filename>, then the output file name is
49-
computed by appending <literal>.c</literal> to the full file name.
45+
preferably have the extension <filename>.pgc</filename>.
46+
The extension will be replaced by <filename>.c</filename> to
47+
determine the output file name.
5048
The output file name can also be overridden using the
5149
<option>-o</option> option.
5250
</para>

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ main(int argc, char *const argv[])
313313
base_yyout = stdout;
314314
else
315315
{
316-
output_filename = mm_strdup(input_filename);
316+
output_filename = mm_alloc(strlen(input_filename) + 3);
317+
strcpy(output_filename, input_filename);
317318

318319
ptr2ext = strrchr(output_filename, '.');
319320
/* make extension = .c resp. .h */

0 commit comments

Comments
 (0)