Fix buffer overflow on particularly named files and clarify documentation about
authorMichael Meskes
Thu, 22 Dec 2016 07:28:13 +0000 (08:28 +0100)
committerMichael Meskes
Thu, 22 Dec 2016 07:28:13 +0000 (08:28 +0100)
output file naming.

Patch by Tsunakawa, Takayuki 

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

index 029bd4a4d2255f8c2c5687d54e8ab59a0e03d2ed..8bfb47c4d79ff813b77d99967d5d481d85260690 100644 (file)
@@ -42,11 +42,9 @@ PostgreSQL documentation
   
    ecpg will convert each input file given on the
    command line to the corresponding C output file.  Input files
-   preferably have the extension .pgc, in which
-   case the extension will be replaced by .c to
-   determine the output file name.  If the extension of the input file
-   is not .pgc, then the output file name is
-   computed by appending .c to the full file name.
+   preferably have the extension .pgc.
+   The extension will be replaced by .c to
+   determine the output file name.
    The output file name can also be overridden using the
     option.
   
index 3b0de973210c121adff461c7a8311cf5b1ab5685..59dce140a93edc95b1c5faf5fd1df4a1e4f4d881 100644 (file)
@@ -313,7 +313,8 @@ main(int argc, char *const argv[])
                    base_yyout = stdout;
                else
                {
-                   output_filename = mm_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 */