Permalink
Commits on Nov 15, 2016
  1. Pre-release 3.5.0

    germanop committed Nov 15, 2016
    Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
  2. CA-222244: Fix resource leaks in vhd_shift_metadata()

    kostaslamda committed with germanop Sep 16, 2016
    There is a case where 'buf' has memory allocated, the pointer
    is not copied to locators[i] yet and we fail. 'buf' will be
    leaked.
    
    Fix:
    - Initialize 'buf' to 'NULL'
    - 'posix_memalign()' will set 'buf' to 'NULL' in case of error;
      remove redundant 'NULL'
    - Set 'buf' to 'NULL' at the end of every iteration in the loop
    - Free 'buf' in 'out'
    
    In the second for loop, if 'vhd_check_for_clobber()' fails, all
    allocated memory is leaked.
    
    Fix:
    Instead of returning -EINVAL, set 'err' to it and go to 'out'.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#226
  3. CA-222242: memset() 1 byte instead of 4

    kostaslamda committed with germanop Sep 16, 2016
    In 'vhd_kill_footer()', we call 'memset()' passing a 4 byte value
    instead of a 1 byte value, as expected. Everything after the first
    byte is truncated.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#225
  4. CA-222139: Resource leak in tap_ctl_allocate_device()

    kostaslamda committed with germanop Sep 15, 2016
    tap_ctl_allocate_device() will allocate memory to *devname, if it does
    not already point to a command line argument. That memory needs to be
    freed in both the success (in the calling function) and failure (in
    the same function) cases.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#223
  5. CA-222077: Fix bugs in td_fdreceiver_start()

    kostaslamda committed with germanop Sep 14, 2016
    - Change socket file descriptor type to 'int';
      need to check for negative returns
    - Check return value of strdup(); fail if 'NULL'
    - Check return value of 'snprintf()'; fail if 'path' is
      truncated or a negative value is returned
    - In case of failure, free 'fdreceiver->path' first
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#222
  6. CA-216249: Check length of socket name before copying

    kostaslamda committed with germanop Sep 14, 2016
    Ensure that string fits in 'sun_path' before copying it over.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#221
  7. CA-222003: Fix NULL dereference bug

    kostaslamda committed with germanop Sep 13, 2016
    In function 'tapdisk_vbd_initialize()' check the return value of
    'tapdisk_vbd_create()' before proceeding; it might be NULL.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#220
  8. CA-221864: Fix bugs in vhd_journal_read_locators()

    kostaslamda committed with germanop Sep 12, 2016
    - Return value from vhd_journal_position() not checked;
      ensure it is valid before continuing
    
    - In case of error inside the for loop, always free 'buf';
      if 'NULL', memory has not been allocated (1st iter) or the
      pointer is already added to '_locators' (all other iters);
      if not 'NULL', pointer not copied to '_locators' yet
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#218
  9. CA-221814: Fix resource leak in vhdi_create()

    kostaslamda committed with germanop Sep 12, 2016
    In case file 'name' fails to open, memory allocated to
    'buf' is leaked.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Stefano Panella <stefano.panella@citrix.com>
    
    GitHub: closes xapi-project/blktap#217
  10. CA-216250: Fix resource leak

    kostaslamda committed with germanop Sep 8, 2016
    In 'vhd_util_coalesce_load_chain()', if there is an error and we
    jump to 'out', 'next' might not be freed.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#214
  11. CA-215114: Resource leak in vhd_util_coalesce_open_output()

    kostaslamda committed with germanop Sep 7, 2016
    There is a case where vhd_open() succeeds (0 is returned) but
    the 'src' and 'dst' header block sizes are different.
    'vhd_util_coalesce_open_output()' returns an error, but 'dst' is
    not properly closed.
    
    These 2 distinct cases (opening the vhd and checking if it is
    correct) are now handled seperately.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#210
  12. CA-220481: Fixes in tap_ctl_stats_fwrite()

    kostaslamda committed with germanop Sep 6, 2016
    - Ensure that 'sysconf()' returns a positive value before assigning
      to 'bufz'. Otherwise, set 'err' and jump to 'out'
    - In case 'mmap()' returns 'MAP_FAILED', do not change 'buf'
      to 'NULL' before jumping to 'out'; if 'buf != MAP_FAILED'
      'munmap(buf, bufsz)' is called
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#207
  13. CP-18757: Refactor the way we use ctx->fd (CID: 28676)

    Sharath Babu committed with germanop Sep 1, 2016
    coverity does not understand the context between
    ctx->file and ctx->fd. Even though we close the fd each time
    we enter vhd_close by checking ctx->file, coverity does not
    understand this relation. To avoid this we need to check
    ctx->fd != -1 instead of ctx->file
    
    Signed-off-by: Sharath Babu <sharath.babu@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#197
  14. Merge CA-220467

    germanop committed Nov 15, 2016
    Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#212
  15. CA-220467 Read or Write to pointer after free

    stefanopanella committed with germanop Sep 7, 2016
    CID-62178 CID-57555 The problem is that tapdisk_nbdserver_reqs_init was calling
    tapdisk_nbdserver_free_request which was potentially freeing
    client without reporting any error, leading to a possible
    segmentation fault.
    
    The fix is to extract a new function from
    tapdisk_nbdserver_free_request which only does the assignment of the req
    without freeing the client and only call this new function
    from tapdisk_nbdserver_reqs_init since we know we will never need to
    free the client from that init context.
    
    Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
    Reviewed-By: Mark Syms <mark.syms@citrix.com>
  16. CA-220467 Double close

    stefanopanella committed with germanop Sep 6, 2016
    CID-28793 Setting server->fdrecv_listening_fd = -1 after the first close
    will avoid the second close.
    
    Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
    Reviewed-By: Mark Syms <mark.syms@citrix.com>
  17. CA-220467: Destination buffer too small

    stefanopanella committed with germanop Sep 6, 2016
    CID-28073 Added check to make sure destination buffer is big enaugh
    for the name wich is going to be copied in.
    
    Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
    Reviewed-By: Mark Syms <mark.syms@citrix.com>
  18. CA-220467: Dereference null return value

    stefanopanella committed with germanop Sep 6, 2016
    CID-28562 Added a check to avoid the segfault in case client is NULL
    
    Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
    Reviewed-By: Mark Syms <mark.syms@citrix.com>
  19. CA-220467 Unchecked return value from library

    stefanopanella committed with germanop Sep 6, 2016
    CID-11258 is complaining that we do not check the result of send
    after calling it. Because of this, I have added the check for the
    return value, not just to see if there is an error, but also to see
    if the send did not manage to send all the data and it needs to be
    called again.
    
    Signed-off-by: Stefano Panella <stefano.panella@citrix.com>
    Reviewed-By: Mark Syms <mark.syms@citrix.com>
Commits on Nov 14, 2016
  1. CA-220482: Check return value of fwrite()

    kostaslamda committed with germanop Sep 6, 2016
    'len' is unused, so do not save the return value of 'fwrite()';
    instead, check that it was successful, and if not, set 'err'
    appropriately.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#208
  2. CA-220518: Potentially uninitialised variable used

    kostaslamda committed with germanop Sep 7, 2016
    In 'vhd_util_coalesce_clear_bitmap()', 'dirty' is used in a truth
    statement, potentially uninitialised.
    
    Initialise to 0.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#213
  3. CA-220479: Remove nonsensical checks

    kostaslamda committed with germanop Sep 6, 2016
    Variable 'len' cannot be negative.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#205
  4. CA-220478: Fix leaked socket file descriptor

    kostaslamda committed with germanop Sep 6, 2016
    In _tap_ctl_stats_connect_and_send(), if tap_ctl_write_message()
    returns an error, 'sfd' is not closed before returning.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#204
  5. CA-220463: Ensure string fits in buffer before copying

    kostaslamda committed with germanop Sep 6, 2016
    'message.u.blkif.pool' is a fixed size char array. Make sure the C
    string pointed to by 'pool' (with the terminateing '\0' char) fits
    before copying it over.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#206
  6. CA-220442: Check length of socket name before copying

    kostaslamda committed with germanop Sep 5, 2016
    'struct sockaddr_un' member 'sun_path' is a fixed size, 108 byte array.
    Check that 'name' is at maximum 107 characters long before copying.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#202
  7. CA-220444: Fix possible race condition

    kostaslamda committed with germanop Sep 5, 2016
    In function tap_ctl_make_device() in tap-ctl-allocate.c, try to unlink
    without checking if the device is there first. If it does not exist, do
    nothing. For all other errors, return 'errno'.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#203
  8. CA-220436: Fix Resource leak in tap-ctl-list.c

    kostaslamda committed with germanop Sep 5, 2016
    Socket fd was being leaked if tap_ctl_write_message() failed in
    _tap_ctl_list_tapdisk().
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#201
  9. CA-220434: Return 'err' instead of 0

    kostaslamda committed with germanop Sep 5, 2016
    In '_tap_ctl_list_tapdisk()', if there is an error before the do loop
    is reached, the error code is returned. However, if there is an error
    in the do loop, 0 is returned.
    
    'err' is saved throughout the function, so return it instead of 0.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#200
  10. CA-220433: Replace 'format' with string literal in tap-ctl-list.c

    kostaslamda committed with germanop Sep 5, 2016
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#199
  11. CA-220226: Fix bugs in part-util.c

    kostaslamda committed with germanop Sep 1, 2016
    - Remove overridden variable assignments
    - Check that 'fd' is non-negative before calling 'close'
    - Change 'sec_size' type from 'int' to 'unsigned int'
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#198
  12. CA-215084: Bug fixes in lvm-util.c

    kostaslamda committed with germanop Sep 1, 2016
    If there were no lines to be consumed by the for loop, 'lvs' and 'pvs'
    would be used uninitialized. When we break out of the loop, we check
    that there has been at least 1 line consumed or we fail.
    
    Signed-off-by: Kostas Ladopoulos <konstantinos.ladopoulos@citrix.com>
    Reviewed-by: Germano Percossi <germano.percossi@citrix.com>
    
    GitHub: closes xapi-project/blktap#196
  13. CA-215080:Uninitialized scalar variable(CID:63812)

    Swathi Kovvuri committed with germanop Sep 1, 2016
    Signed-off-by: Swathi Kovvuri <swathi.kovvuri@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#186
  14. CA-220003: Resource leak for memory allocated to target (CID:57413)

    Sharath Babu committed with germanop Sep 1, 2016
    Signed-off-by: Sharath Babu <sharath.babu@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#195
  15. CA-220002: resource leak for memory allocated to pname (CID:57549)

    Sharath Babu committed with germanop Aug 31, 2016
    Signed-off-by: Sharath Babu <sharath.babu@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#194
  16. CA-220000: memory leak from variable path (CID:57593)

    Sharath Babu committed with germanop Aug 31, 2016
    Signed-off-by: Sharath Babu <sharath.babu@citrix.com>
    Reviewed-by: Mark Syms <mark.syms@citrix.com>
    
    GitHub: closes xapi-project/blktap#193