]> granicus.if.org Git - postgresql/commitdiff
Fix buffer overflow on particularly named files and clarify documentation about
authorMichael Meskes <meskes@postgresql.org>
Thu, 22 Dec 2016 07:28:13 +0000 (08:28 +0100)
committerMichael Meskes <meskes@postgresql.org>
Thu, 22 Dec 2016 07:34:07 +0000 (08:34 +0100)
output file naming.

Patch by Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>

doc/src/sgml/ref/ecpg-ref.sgml
src/interfaces/ecpg/preproc/ecpg.c

index edd20dcdd557526cbcb07ff86104093ba39113e4..226a9caa4d968d19d4a74a1484d9046c0cdd1929 100644 (file)
@@ -42,11 +42,9 @@ PostgreSQL documentation
   <para>
    <command>ecpg</command> will convert each input file given on the
    command line to the corresponding C output file.  Input files
-   preferably have the extension <filename>.pgc</filename>, in which
-   case the extension will be replaced by <filename>.c</filename> to
-   determine the output file name.  If the extension of the input file
-   is not <filename>.pgc</filename>, then the output file name is
-   computed by appending <literal>.c</literal> to the full file name.
+   preferably have the extension <filename>.pgc</filename>.
+   The extension will be replaced by <filename>.c</filename> to
+   determine the output file name.
    The output file name can also be overridden using the
    <option>-o</option> option.
   </para>
index d09dc48ef469ccbda6277746629b4e2daa8ab14b..081d2ea345f9f63534e61e489aad0d6b949e6701 100644 (file)
@@ -309,7 +309,8 @@ main(int argc, char *const argv[])
                                        base_yyout = stdout;
                                else
                                {
-                                       output_filename = strdup(input_filename);
+                                       output_filename = mm_alloc(strlen(input_filename) + 3);
+                                       strcpy(output_filename, input_filename);
 
                                        ptr2ext = strrchr(output_filename, '.');
                                        /* make extension = .c resp. .h */