Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#13 Fixes for static analysis issues

open
nobody
None
5
2014-08-21
2012-01-27
Honza Horak
No

Linux UDF 1.0.0b3 has been scanned using Coverity static analysis tool and these are issues found (fixes for some obvious bugs will be attached as a suggested patch):

Error: DEADCODE:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:685: dead_error_condition: On this path, the condition "len == 0U" cannot be true.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:683: at_least: After this line, the value of "len" is at least 2048.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:700: assignment: Assigning: "len" = "len - 2048U".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:685: equality_cond: Condition "len == 0U" is evaluated as false.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:683: new_values: Noticing condition "len < 2048U".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:686: dead_error_line: Execution cannot reach this statement "if (usesShort){
sh++;
l...".

Error: DEADCODE:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:160: dead_error_condition: On this path, the condition "inMainSeq" cannot be false.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:157: const: After this line, the value of "inMainSeq" is equal to 1.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:157: assignment: Assigning: "inMainSeq" = "1".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:161: dead_error_line: Execution cannot reach this statement "fail("Volume Descriptor Seq...".

Error: FORWARD_NULL:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:159: var_compare_op: Comparing "p" to null implies that "p" might be null.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:167: var_deref_op: Dereferencing null variable "p".

Error: OVERRUN_STATIC:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:528: overrun-buffer-val: Overrunning struct type struct fileEntry of size 176 bytes by passing it as an argument to a function which indexes it at byte position 2047.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cdrw.c:605: access_dbuff_const: Calling "memcpy" indexes array "src" with index "2048UL" at byte position 2047.

Error: OVERRUN_STATIC:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:633: overrun-buffer-arg: Overrunning struct type struct fileEntry of size 176 bytes by passing it to a function which indexes it with argument "2048UL" at byte position 2047.

Error: OVERRUN_STATIC:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:396: overrun-buffer-arg: Overrunning struct type struct fileEntry of size 176 bytes by passing it to a function which indexes it with argument "2048UL" at byte position 2047.

Error: OVERRUN_STATIC:
/builddir/build/BUILD/udftools-1.0.0b3/mkudffs/options.c:260: assignment: Assigning: "media" = "2".
/builddir/build/BUILD/udftools-1.0.0b3/mkudffs/options.c:354: overrun-local: Overrunning static array "default_sizing", with 4 elements, at position 4 with index variable "media".

Error: RESOURCE_LEAK:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:69: alloc_fn: Calling allocation function "makeFileEntry".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:162: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:162: var_assign: Assigning: "fe" = "calloc(2048UL, 1UL)".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:180: return_alloc: Returning allocated memory "fe".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:69: var_assign: Assigning: "fe" = storage returned from "makeFileEntry()".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:110: leaked_storage: Variable "fe" going out of scope leaks the storage it points to.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:196: leaked_storage: Variable "fe" going out of scope leaks the storage it points to.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:206: leaked_storage: Variable "fe" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:67: alloc_fn: Calling allocation function "makeFileIdentDesc".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:195: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:195: var_assign: Assigning: "fid" = "calloc(512UL, 1UL)".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-desc.c:208: return_alloc: Returning allocated memory "fid".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:67: var_assign: Assigning: "fid" = storage returned from "makeFileIdentDesc(newName)".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:110: leaked_storage: Variable "fid" going out of scope leaks the storage it points to.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:196: leaked_storage: Variable "fid" going out of scope leaks the storage it points to.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:206: leaked_storage: Variable "fid" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:55: open_fn: Calling opening function "open".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:55: var_assign: Assigning: "fd" = handle returned from "open(inName, 0)".
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:65: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:110: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:196: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:206: leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/udftools-1.0.0b3/cdrwtool/cdrwtool.c:311: open_fn: Calling opening function "open".
/builddir/build/BUILD/udftools-1.0.0b3/cdrwtool/cdrwtool.c:311: var_assign: Assigning: "file" = handle returned from "open(disc->filename, 0)".
/builddir/build/BUILD/udftools-1.0.0b3/cdrwtool/cdrwtool.c:326: leaked_handle: Handle variable "file" going out of scope leaks the handle.

Error: SIZECHECK:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf.c:291: ampersand_in_size: Calling allocating function "malloc" with a size argument that contains an ampersand: "len + 2047U & 0xfffff800U".

Error: SIZEOF_MISMATCH:
/builddir/build/BUILD/udftools-1.0.0b3/mkudffs/mkudffs.c:45: suspicious_sizeof: Passing argument "disc" of type "struct udf_disc *" and argument "8UL /* sizeof (disc) */" to function "memset" is suspicious. Did you intend to use "sizeof(*disc)" instead of "sizeof (disc)" ?

Error: UNUSED_VALUE:
/builddir/build/BUILD/udftools-1.0.0b3/libudffs/file.c:123: returned_pointer: Pointer "fiddesc" returned by "set_desc(disc, pspace, 257, block, data->length, data)" is never used.

Error: UNUSED_VALUE:
/builddir/build/BUILD/udftools-1.0.0b3/libudffs/file.c:197: returned_pointer: Pointer "fiddesc" returned by "set_desc(disc, pspace, 257, block, data->length, data)" is never used.

Error: UNUSED_VALUE:
/builddir/build/BUILD/udftools-1.0.0b3/mkudffs/mkudffs.c:832: returned_pointer: Pointer "ext" returned by "next_extent(disc->head, PSPACE)" is never used.

Error: UNUSED_VALUE:
/builddir/build/BUILD/udftools-1.0.0b3/wrudf/wrudf-cmnd.c:801: returned_pointer: Pointer "newFid" returned by "findFileIdentDesc(curDir, srcname)" is never used.

Discussion