Merge pull request #1361 from ZoneMinder/fix_coverity_issues

Fix coverity issues
This commit is contained in:
Andrew Bauer 2016-03-26 21:11:28 -05:00
commit ffc0ebaf22
5 changed files with 20 additions and 15 deletions

View File

@ -119,13 +119,16 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
struct stat statbuf;
errno = 0;
stat( path, &statbuf );
if ( stat( path, &statbuf ) ) {
if ( errno == ENOENT || errno == ENOTDIR )
{
if ( mkdir( path, 0755 ) )
{
Fatal( "Can't mkdir %s: %s", path, strerror(errno));
}
} else {
Warning( "Error stat'ing %s, may be fatal. error is %s", path, strerror(errno));
}
}
if ( i == 2 )
strncpy( date_path, path, sizeof(date_path) );

View File

@ -342,10 +342,10 @@ Monitor::Monitor(
images( 0 ),
privacy_bitmask( NULL )
{
strncpy( name, p_name, sizeof(name) );
strncpy( name, p_name, sizeof(name)-1 );
strncpy( event_prefix, p_event_prefix, sizeof(event_prefix) );
strncpy( label_format, p_label_format, sizeof(label_format) );
strncpy( event_prefix, p_event_prefix, sizeof(event_prefix)-1 );
strncpy( label_format, p_label_format, sizeof(label_format)-1 );
// Change \n to actual line feeds
char *token_ptr = label_format;

View File

@ -301,9 +301,6 @@ protected:
const unsigned char *privacy_bitmask;
int iDoNativeMotDet;
int n_linked_monitors;
MonitorLink **linked_monitors;

View File

@ -201,8 +201,8 @@ std::string Authenticator::computeDigestResponse(std::string &method, std::strin
return md5HexBuf;
#else // HAVE_DECL_MD5
Error( "You need to build with gnutls or openssl installed to use digest authentication" );
#endif // HAVE_DECL_MD5
return( 0 );
#endif // HAVE_DECL_MD5
}
void Authenticator::checkAuthResponse(std::string &response) {

View File

@ -294,7 +294,12 @@ void StreamBase::openComms()
snprintf( sock_path_lock, sizeof(sock_path_lock), "%s/zms-%06d.lock", config.path_socks, connkey);
lock_fd = open(sock_path_lock, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR);
if (lock_fd <= 0 || flock(lock_fd, LOCK_EX) != 0)
if ( lock_fd <= 0 )
{
Error("Unable to open sock lock file %s: %s", sock_path_lock, strerror(errno) );
lock_fd = 0;
}
else if ( flock(lock_fd, LOCK_EX) != 0 )
{
Error("Unable to lock sock lock file %s: %s", sock_path_lock, strerror(errno) );