[Libburn] Looking at the libburn code

Philip Martin philip at codematters.co.uk
Tue Feb 14 16:19:41 PST 2006


I've just had a look at some of the libburn code for the first time
and there are a few issues that I see:

- The pthread_mutex_xxx functions all have return values but these are
  ignored by the libburn code.  These functions are unlikely to fail,
  but assuming they won't fail is a bit of a gamble.

- Calls to write(2) and close(2) don't have their return value
  checked, these calls could fail.

- The pthread_create return value is checked but the libburn code
  doesn't do anything sensible -- the calling function returns no
  error but the linked list refers to free'd memory.  Again, it's
  unlikely to happen, but it's not impossible.

- A pthread_mutex_t is copied when enumerate_common calls
  burn_drive_register in sg.c.  POSIX classifies that as undefined
  behaviour, although it works on lots of systems.

- There is no call to pthread_mutex_destroy, that could be a problem
  on some platforms.

- There is a realloc call in structure.c that doesn't make use the
  return value.  I assume it's reducing the memory allocation and so
  the memory is unlikely to be moved, but it's still not portable.

- Some of the files have unnecessary includes, e.g. sbc.c, others
  don't have includes for things they use, e.g. transport.h doesn't
  include pthread.h and relies on sys/types.h pulling in something
  suitable.

- Is burn_wait_all supposed to sleep?  The current implementation
  would appear to skip the sleep.

I regard all of the above as bugs, although some of them will rarely
if ever affect Linux.  Is the project interested in fixing them?

-- 
Philip Martin


More information about the libburn mailing list