From 16d338b2abf2b334f0ddb03bd7da60799e952cd7 Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 3 Jul 2003 20:39:47 +0000 Subject: [PATCH] Made SQL buffers bigger to prevent overflow. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@588 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm_event.cpp | 8 ++++---- src/zm_monitor.cpp | 6 +++--- src/zm_zone.cpp | 4 ++-- src/zmfix.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 032cd2e91..5e28d5dc3 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -32,7 +32,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_monitor ), start_time( p_start_time ) { - static char sql[256]; + static char sql[BUFSIZ]; static char start_time_str[32]; strftime( start_time_str, sizeof(start_time_str), "%Y-%m-%d %H:%M:%S", localtime( &start_time.tv_sec ) ); @@ -63,7 +63,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_mon Event::~Event() { - static char sql[256]; + static char sql[BUFSIZ]; static char end_time_str[32]; struct DeltaTimeval delta_time; @@ -239,7 +239,7 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, const Image DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); Debug( 1, ( "Adding frame %d to DB", frames )); - static char sql[256]; + static char sql[BUFSIZ]; sprintf( sql, "insert into Frames ( EventId, FrameId, AlarmFrame, ImagePath, Delta, Score ) values ( %d, %d, %d, '%s', %s%ld.%02ld, %d )", id, frames, alarm_image!=0, event_file, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); if ( mysql_query( &dbconn, sql ) ) { @@ -266,7 +266,7 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, const Image void Event::StreamEvent( const char *path, int event_id, long refresh, FILE *fd ) { - static char sql[256]; + static char sql[BUFSIZ]; sprintf( sql, "select Id, EventId, ImagePath, Delta from Frames where EventId = %d order by Id", event_id ); if ( mysql_query( &dbconn, sql ) ) { diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index ab9fd82c5..c65e9a9c1 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -605,7 +605,7 @@ void Monitor::ReloadZones() int Monitor::Load( int device, Monitor **&monitors, Mode mode ) { - static char sql[256]; + static char sql[BUFSIZ]; if ( device == -1 ) { strcpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local'" ); @@ -651,7 +651,7 @@ int Monitor::Load( int device, Monitor **&monitors, Mode mode ) int Monitor::Load( const char *host, const char*port, const char *path, Monitor **&monitors, Mode mode ) { - static char sql[256]; + static char sql[BUFSIZ]; if ( !host ) { strcpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote'" ); @@ -697,7 +697,7 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor Monitor *Monitor::Load( int id, bool load_zones, Mode mode ) { - static char sql[256]; + static char sql[BUFSIZ]; sprintf( sql, "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id ); if ( mysql_query( &dbconn, sql ) ) { diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index c308d6d44..7adff27a2 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -65,7 +65,7 @@ Zone::~Zone() void Zone::RecordStats( const Event *event ) { - static char sql[256]; + static char sql[BUFSIZ]; sprintf( sql, "insert into Stats set MonitorId=%d, ZoneId=%d, EventId=%d, FrameId=%d, AlarmPixels=%d, FilterPixels=%d, BlobPixels=%d, Blobs=%d, MinBlobSize=%d, MaxBlobSize=%d, MinX=%d, MinY=%d, MaxX=%d, MaxY=%d, Score=%d", monitor->Id(), id, event->Id(), event->Frames()+1, alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, min_blob_size, max_blob_size, alarm_box.LoX(), alarm_box.LoY(), alarm_box.HiX(), alarm_box.HiY(), score ); if ( mysql_query( &dbconn, sql ) ) { @@ -394,7 +394,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) int Zone::Load( Monitor *monitor, Zone **&zones ) { - static char sql[256]; + static char sql[BUFSIZ]; sprintf( sql, "select Id,Name,Type+0,Units,LoX,LoY,HiX,HiY,AlarmRGB,AlarmThreshold,MinAlarmPixels,MaxAlarmPixels,FilterX,FilterY,MinFilterPixels,MaxFilterPixels,MinBlobPixels,MaxBlobPixels,MinBlobs,MaxBlobs from Zones where MonitorId = %d order by Type, Id", monitor->Id() ); if ( mysql_query( &dbconn, sql ) ) { diff --git a/src/zmfix.cpp b/src/zmfix.cpp index 9433f8337..41efd3a4a 100644 --- a/src/zmfix.cpp +++ b/src/zmfix.cpp @@ -105,7 +105,7 @@ int main( int argc, char *argv[] ) // Only do registered devices zmDbConnect( ZM_DB_USERA, ZM_DB_PASSA ); - static char sql[256]; + static char sql[BUFSIZ]; //sprintf( sql, "select distinct Device from Monitors where Function != 'None' and Type = 'Local'" ); sprintf( sql, "select distinct Device from Monitors where Type = 'Local'" ); if ( mysql_query( &dbconn, sql ) )