Set of patch to address several Coverity issues

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Set of patch to address several Coverity issues
Date: 2015-07-07 07:17:47
Message-ID: CAB7nPqRqip_N_FnBgadnc_MY_SrFBf0gW2W7HGHLOK_wyc_UiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

As there have been complaints that it was hard to follow all the small
patches I have sent to fix the issues related to Coverity, here they
are gathered with patches for each one of them:
1) Missing return value checks in jsonfuncs.c, fixed by 0001 (send
here previously =>
CAB7nPqQcj3hU9P7a6VUHoMepJkOYQrjXnT1g2f7Qy_CQ0Q8G_g(at)mail(dot)gmail(dot)com)
JsonbIteratorNext is missing a set of (void) in front of its calls.
2) Potential pointer dereference in plperl.c, fixed by 0002 (sent
previously here =>
CAB7nPqRBCWAXTLw0yBR=BK94cRYXU8TWVxGyYoxautw08OKeXw(at)mail(dot)gmail(dot)com).
This is related to a change done by transforms. In short,
plperl_call_perl_func(at)plperl(dot)c will have a pointer dereference if
desc->arg_arraytype[i] is InvalidOid. And AFAIK,
fcinfo->flinfo->fn_oid can be InvalidOid in this code path.
3) visibilitymap_truncate and FreeSpaceMapTruncateRel are doing a
NULL-pointer check on rel->rd_smgr but it has been dereferenced in all
the code paths leading to those checks. See 0003. For code readability
mainly.
4) Return result of timestamp2tm is not checked 2 times in
GetCurrentDateTime and GetCurrentTimeUsec, while all the other 40
calls of this function do sanity checks. Returning
ERRCODE_DATETIME_VALUE_OUT_OF_RANGE in case of an error would be good
for consistency. See 0004. (issue reported previously here
CAB7nPqRSk=J8eUdd55fL-w+k=8sDTHLVBt-cgG9jWN=VO2ogBQ(at)mail(dot)gmail(dot)com)

Each issue is independent, please feel free to comment.
Regards,
--
Michael

Attachment Content-Type Size
0001-Fix-missing-return-value-checks-for-JsonbIteratorNex.patch text/x-diff 1.0 KB
0002-Fix-pointer-dereference-in-plperl-caused-by-transfor.patch text/x-diff 1.4 KB
0003-Remove-unnecessary-NULL-pointer-checks.patch text/x-diff 1.6 KB
0004-Check-return-values-of-timestamp2tm.patch text/x-diff 1.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2015-07-07 07:27:38 Re: RFC: replace pg_stat_activity.waiting with something more descriptive
Previous Message Jeff Davis 2015-07-07 06:59:27 Re: Memory Accounting v11