svace fixes: insufficient error handling 02/152602/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 26 Sep 2017 11:29:32 +0000 (13:29 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 28 Sep 2017 14:14:53 +0000 (14:14 +0000)
commit79829655590e47ae16848dfea96ba7ce4c7bd09e
tree06fa6fd3fd444981b3d6e40e874b5d221e511e73
parent9ef91ff21981c0a2f6c122dbc47bd1749f16e82d
svace fixes: insufficient error handling

This commit brings fixes for folowing SVACE-reported issues:

    * UNCHECKED_FUNC_RES.FREAD: Return value of fread function was compared to zero at crash-stack.c:836, but ferror/feof wasn't called.
      Result was compared with zero at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:836

    * HANDLE_LEAK: The handle 'fd' was created at crash-manager.c:508 by calling function 'open' and lost at crash-manager.c:515.
      [acquire] Call of open at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-manager/crash-manager.c:508
      [leaked] leaked at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-manager/crash-manager.c:515

    * DEREF_OF_NULL.CONST: Pointer '&tail->next', which was assigned NULL value at crash-stack.c:642, is dereferenced at crash-stack.c:692.
      [dereference] Variable '&tail->next' is dereferenced at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:692
      [null] Assign null at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:642

    * RACE.NO_UMASK: Function 'umask(077)' needs to be called before 'mkstemp' at crash-stack.c:964, to prevent a potential race condition vulnerability.
      function call at /home/abuild/rpmbuild/BUILD/crash-worker-1.0.1/src/crash-stack/crash-stack.c:964

Change-Id: Ief6dd93ec8d795fccffbc2d823a6af8fcf63c965
src/crash-manager/crash-manager.c
src/crash-stack/crash-stack.c