zoneminder: adjust fix for printf/time_t

Rather than casting to long, cast to intmax_t and print with %jd, as
suggested by joerg@.
This commit is contained in:
gdt 2018-07-14 15:03:57 +00:00
parent e27e90a9ef
commit 12e40ac41f
6 changed files with 46 additions and 25 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.38 2018/07/13 02:05:11 gdt Exp $
# $NetBSD: Makefile,v 1.39 2018/07/14 15:03:57 gdt Exp $
PKGNAME= ${DISTNAME:S/ZoneMinder-/zoneminder-/}
DISTNAME= ZoneMinder-1.28.1
PKGREVISION= 16
PKGREVISION= 17
CATEGORIES= security
MASTER_SITES= ${MASTER_SITE_GITHUB:=ZoneMinder/}
GITHUB_PROJECT= ZoneMinder

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.11 2018/07/13 02:05:11 gdt Exp $
$NetBSD: distinfo,v 1.12 2018/07/14 15:03:57 gdt Exp $
SHA1 (ZoneMinder-1.28.1.tar.gz) = 3e173ae1aac529b60d79a5fc668c107f0679d0a2
RMD160 (ZoneMinder-1.28.1.tar.gz) = b3cc305656cb5b73d4ac0e21fe937c237467cdd1
@ -9,9 +9,9 @@ SHA1 (patch-configure_ac) = 110a7a10506ba931369904d777dec5cc2185f556
SHA1 (patch-scripts_ZoneMinder_lib_ZoneMinder_General_pm) = 841d897662958698a4dfcb95dd5bc43bb5fed568
SHA1 (patch-scripts_zm_in) = 8f59085bb9293afa7aeb268000c75988e5371c66
SHA1 (patch-src_Makefile_am) = 0f6571c9d5a3e688544f93d687d266e1b71f0f43
SHA1 (patch-src_zm__event.cpp) = 2db5a2f85039e711ab6a18af816e0269611fc5f2
SHA1 (patch-src_zm__event.cpp) = 5258e89486b1152f0ddcac9b0a6fd68b70f24256
SHA1 (patch-src_zm__monitor.cpp) = dcc3816686a6a7c375d4716d3663b4c922c90439
SHA1 (patch-src_zm__rtp__source.cpp) = eecca36c18a6611745c49686499a16df177abc7f
SHA1 (patch-src_zm__rtp__source.cpp) = 5341938eefe5def49dc8f3e3b760d86cabd17772
SHA1 (patch-src_zm__sdp.cpp) = ed89bc14ae557281bb43baca9c90b78d801d8eb1
SHA1 (patch-src_zm__thread.h) = 67dbd1e9c19df63fd120344cc8a36d663a724409
SHA1 (patch-src_zm__timer.h) = 38080d08b5834e3dae713e81488944887ce5848b
@ -20,12 +20,12 @@ SHA1 (patch-src_zm__utils.h) = dbda8ba527f08b0337f6d2afa155ce4adc733e1e
SHA1 (patch-src_zm_comms_cpp) = d40932a3d0ae4375a649f200d973995d56aa71c7
SHA1 (patch-src_zm_comms_h) = baeb73040ff3ba862f23ad6301de7daba182456e
SHA1 (patch-src_zm_ffmpeg_camera_cpp) = 6ead5f9afbe984aab14fee337093fd0269c6e9d8
SHA1 (patch-src_zm_logger_cpp) = 6e0124756ef6fe58fb452651337d622ddff6c4ab
SHA1 (patch-src_zm_logger_cpp) = c4d33648d28962fb0e211277caa8c5b1f829538a
SHA1 (patch-src_zm_remote_camera_h) = 0d4bd7dae0188df7e463586250ac2ed530230f3d
SHA1 (patch-src_zm_signal_cpp) = fa11938f55ccd50a1a9e949d6b58dd07773f2690
SHA1 (patch-src_zm_thread_cpp) = c5f64697c3024c6c382f9ae2c5dbe9c21b529b6e
SHA1 (patch-src_zmc_cpp) = d1046ddfad3a88bdd30501237834ec9e9fbc4c83
SHA1 (patch-src_zmf.cpp) = a059b9ae068037c6f68c16dab861ed830dd1c7e2
SHA1 (patch-src_zmu.cpp) = a95e81285167fc8df77bc059c7b7f09cc36ff922
SHA1 (patch-src_zmu.cpp) = c83283c1ac38e7c39201f72099b9830d84566c41
SHA1 (patch-web_Makefile.am) = ddb3815fa1b1799658034789302c8d3840f2b894
SHA1 (patch-web_ajax_stream_php) = e8f811e63bedec03345b74db72c3d8014b3cc7f6

View file

@ -1,4 +1,4 @@
$NetBSD: patch-src_zm__event.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
$NetBSD: patch-src_zm__event.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
zoneminder uses %ld for time_t, which is troublesome on NetBSD mrm and
presumably i386. (Note that there are multiple patch files for the
@ -15,7 +15,7 @@ Also, this fix is expedient and probably a better fix is appropriate.
struct tm *stime = localtime( &start_time.tv_sec );
- snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() );
+ snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), (long) start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() );
+ snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %jd ), %d, %d, '%s', '%s' )", monitor->Id(), (intmax_t) start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() );
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't insert event: %s", mysql_error( &dbconn ) );
@ -24,7 +24,7 @@ Also, this fix is expedient and probably a better fix is appropriate.
Debug( 1, "Adding closing frame %d to DB", frames );
static char sql[ZM_SQL_SML_BUFSIZ];
- snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
+ snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, (long) end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
+ snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %jd ), %s%ld.%02ld )", id, frames, (intmax_t) end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
@ -33,7 +33,7 @@ Also, this fix is expedient and probably a better fix is appropriate.
DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 );
- snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
+ snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, (long) end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
+ snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %jd ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, (intmax_t) end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id );
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't update event: %s", mysql_error( &dbconn ) );
@ -42,7 +42,7 @@ Also, this fix is expedient and probably a better fix is appropriate.
int sql_len = strlen(sql);
- snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
+ snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, (long) timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
+ snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime( %jd ), %s%ld.%02ld ), ", id, frames, (intmax_t) timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
frameCount++;
}
@ -51,7 +51,16 @@ Also, this fix is expedient and probably a better fix is appropriate.
Debug( 1, "Adding frame %d to DB", frames );
static char sql[ZM_SQL_MED_BUFSIZ];
- snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
+ snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, (long) timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
+ snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %jd ), %s%ld.%02ld, %d )", id, frames, frame_type, (intmax_t) timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
if ( mysql_query( &dbconn, sql ) )
{
Error( "Can't insert frame: %s", mysql_error( &dbconn ) );
@@ -656,7 +656,7 @@ bool EventStream::loadInitialEventData(
{
static char sql[ZM_SQL_SML_BUFSIZ];
- snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %ld order by Id asc limit 1", monitor_id, event_time );
+ snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %jd order by Id asc limit 1", monitor_id, (intmax_t) event_time );
if ( mysql_query( &dbconn, sql ) )
{

View file

@ -1,4 +1,4 @@
$NetBSD: patch-src_zm__rtp__source.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
$NetBSD: patch-src_zm__rtp__source.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
--- src/zm_rtp_source.cpp.orig 2015-02-05 02:52:37.000000000 +0000
+++ src/zm_rtp_source.cpp
@ -7,7 +7,7 @@ $NetBSD: patch-src_zm__rtp__source.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
struct timeval ntpTime = tvMake( ntpTimeSecs, suseconds_t((USEC_PER_SEC*(ntpTimeFrac>>16))/(1<<16)) );
- Debug( 5, "ntpTime: %ld.%06ld, rtpTime: %x", ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
+ Debug( 5, "ntpTime: %ld.%06ld, rtpTime: %x", (long) ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
+ Debug( 5, "ntpTime: %jd.%06ld, rtpTime: %x", (intmax_t) ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
if ( mBaseTimeNtp.tv_sec == 0 )
{
@ -17,8 +17,8 @@ $NetBSD: patch-src_zm__rtp__source.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
{
- Debug( 5, "lastSrNtpTime: %ld.%06ld, rtpTime: %x", mLastSrTimeNtp.tv_sec, mLastSrTimeNtp.tv_usec, rtpTime );
- Debug( 5, "ntpTime: %ld.%06ld, rtpTime: %x", ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
+ Debug( 5, "lastSrNtpTime: %ld.%06ld, rtpTime: %x", (long) mLastSrTimeNtp.tv_sec, mLastSrTimeNtp.tv_usec, rtpTime );
+ Debug( 5, "ntpTime: %ld.%06ld, rtpTime: %x", (long) ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
+ Debug( 5, "lastSrNtpTime: %jd.%06ld, rtpTime: %x", (intmax_t) mLastSrTimeNtp.tv_sec, mLastSrTimeNtp.tv_usec, rtpTime );
+ Debug( 5, "ntpTime: %jd.%06ld, rtpTime: %x", (intmax_t) ntpTime.tv_sec, ntpTime.tv_usec, rtpTime );
double diffNtpTime = tvDiffSec( mBaseTimeNtp, ntpTime );
uint32_t diffRtpTime = rtpTime - mBaseTimeRtp;

View file

@ -1,4 +1,4 @@
$NetBSD: patch-src_zm_logger_cpp,v 1.4 2018/07/13 02:05:11 gdt Exp $
$NetBSD: patch-src_zm_logger_cpp,v 1.5 2018/07/14 15:03:57 gdt Exp $
If the system has syscall() but not SYS_gettid [E.g. NetBSD], don't attempt
to use SYS_gettid.
@ -27,7 +27,7 @@ to use SYS_gettid.
mysql_real_escape_string( &mDbConnection, escapedString, syslogStart, strlen(syslogStart) );
- snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
+ snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", (long) timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
+ snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( %jd.%06ld, '%s', %d, %d, '%s', '%s', '%s', %d )", (intmax_t) timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), tid, level, classString, escapedString, file, line );
if ( mysql_query( &mDbConnection, sql ) )
{
databaseLevel( NOLOG );

View file

@ -1,4 +1,4 @@
$NetBSD: patch-src_zmu.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
$NetBSD: patch-src_zmu.cpp,v 1.2 2018/07/14 15:03:57 gdt Exp $
--- src/zmu.cpp.orig 2015-02-05 02:52:37.000000000 +0000
+++ src/zmu.cpp
@ -7,25 +7,37 @@ $NetBSD: patch-src_zmu.cpp,v 1.1 2018/07/13 02:05:11 gdt Exp $
{
if ( have_output ) printf( "%c", separator );
- printf( "%ld.%02ld", timestamp.tv_sec, timestamp.tv_usec/10000 );
+ printf( "%ld.%02ld", (long) timestamp.tv_sec, timestamp.tv_usec/10000 );
+ printf( "%jd.%02ld", (intmax_t) timestamp.tv_sec, timestamp.tv_usec/10000 );
have_output = true;
}
}
@@ -729,7 +729,7 @@ int main( int argc, char *argv[] )
@@ -724,12 +724,12 @@ int main( int argc, char *argv[] )
if ( monitor && monitor->connect() )
{
struct timeval tv = monitor->GetTimestamp();
- printf( "%4d%5d%6d%9d%11ld.%02ld%6d%6d%8d%8.2f\n",
+ printf( "%4d%5d%6d%9d%11jd.%02ld%6d%6d%8d%8.2f\n",
monitor->Id(),
function,
monitor->GetState(),
monitor->GetTriggerState(),
- tv.tv_sec, tv.tv_usec/10000,
+ (long) tv.tv_sec, tv.tv_usec/10000,
+ (intmax_t) tv.tv_sec, tv.tv_usec/10000,
monitor->GetLastReadIndex(),
monitor->GetLastWriteIndex(),
monitor->GetLastEvent(),
@@ -746,7 +746,7 @@ int main( int argc, char *argv[] )
@@ -741,12 +741,12 @@ int main( int argc, char *argv[] )
else
{
struct timeval tv = { 0, 0 };
- printf( "%4d%5d%6d%9d%11ld.%02ld%6d%6d%8d%8.2f\n",
+ printf( "%4d%5d%6d%9d%11jd.%02ld%6d%6d%8d%8.2f\n",
mon_id,
function,
0,
0,
- tv.tv_sec, tv.tv_usec/10000,
+ (long) tv.tv_sec, tv.tv_usec/10000,
+ (intmax_t) tv.tv_sec, tv.tv_usec/10000,
0,
0,
0,