Lack of Sanity Checking in file 'misc.c' for PostgreSQL 9.4.x

Поиск
Список
Период
Сортировка
От Bill Parker
Тема Lack of Sanity Checking in file 'misc.c' for PostgreSQL 9.4.x
Дата
Msg-id CAFrbyQy2U+OrNpqxdnLfXxEiO5M3RVr4SoS7Hrg3srBO8KS9dw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Lack of Sanity Checking in file 'misc.c' for PostgreSQL 9.4.x  (Michael Paquier <michael.paquier@gmail.com>)
Re: Lack of Sanity Checking in file 'misc.c' for PostgreSQL 9.4.x  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name               : Bill Parker
Your email address      : wp02855 at gmail dot com

System Configuration:
---------------------
  Architecture (example: Intel Pentium)         :  x86/x86-64/AMD

  Operating System (example: Linux 2.4.18)      :  Linux 3.11.6-4

  PostgreSQL version (example: PostgreSQL 9.4.3):  PostgreSQL 9.4.x

  Compiler used (example: gcc 3.3.5)            :  gcc version 4.8.1

Please enter a FULL description of your problem:
------------------------------------------------

Hello All,

   In reviewing some code, in directory 'postgresql-9.4.3/src/interfaces/ecpg/ecpglib',
file 'misc.c', there are several instances where a call to malloc()
is made, but no check for a return value of NULL is made, which
would indicate failure.   Additionally, if sqlca = malloc() fails,
ecpg_init_sqlca would be called with variable 'sqlca' equal to NULL?

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

The patch file below addresses these issues:

--- misc.c.orig 2015-06-11 09:23:13.807020490 -0700
+++ misc.c      2015-06-11 09:32:10.077177669 -0700
@@ -143,6 +143,9 @@
        if (sqlca == NULL)
        {
                sqlca = malloc(sizeof(struct sqlca_t));
+               if (sqlca == NULL) {    /*  malloc() failed, now what should we do? */
+                   ecpg_log("Unable to allocate memory in ECPGget_sqlca()\n");
+               }
                ecpg_init_sqlca(sqlca);
                pthread_setspecific(sqlca_key, sqlca);
        }
       
Please feel free to review and comment on the above patch file...

I am attaching the patch file to this bug report

Bill Parker (wp02855 at gmail dot com)

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Bill Parker
Дата:
Сообщение: Lack of Sanity Checking in file 'pctcl.c' for PostgreSQL 9.4.x
Следующее
От: Venkata Balaji N
Дата:
Сообщение: Re: BUG #13431: install readline not complete