From 2d1481c8e62de90b7b6c1b709dfae57a78d0c18a Mon Sep 17 00:00:00 2001 From: Keith Thorne <keith.thorne@ligo.org> Date: Thu, 5 May 2016 21:31:16 +0000 Subject: [PATCH] Bug 1010: protect filesys.hh from divide-by-zero if num_dir is 0 git-svn-id: https://redoubt.ligo-wa.caltech.edu/svn/advLigoRTS/trunk@4209 6dcd42c9-f523-4c6d-aada-af552506706e --- NEWS | 9 +++++++-- src/daqd/filesys.hh | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 9420a6f91..1a0b3062d 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,16 @@ + +================================================================================================== +Changes for X.X +================================================================================================== +- Bug Fix (472): Better framewriter error messages +- Bug Fix (985): Fix daqd for single-machine framebuilder in kernel 3.2 +- Bug Fix (1010): Prevent divide-by-zero error in daqd filesys.hh ================================================================================================== Changes for 3.0.2 ================================================================================================== - Bug Fix to SUM.pm part connection checking. - Bug Fix to auto-generated ADC monitor screens. Screens for models which use several top level signal names were not being generated correctly. -- Bug Fix (472): Better framewriter error messages -- Bug Fix (985): Fix daqd for single-machine framebuilder in kernel 3.2 ================================================================================================== Changes for 3.0.1 ================================================================================================== diff --git a/src/daqd/filesys.hh b/src/daqd/filesys.hh index c0322eb9b..f2f6fcc9b 100644 --- a/src/daqd/filesys.hh +++ b/src/daqd/filesys.hh @@ -395,8 +395,13 @@ static const int digits_in_dir = 5; dnum = cur_update_dir; // Switch to the next directory if current directory is full - if (dir [cur_update_dir].nfiles >= files_per_dir) - ++dnum %= num_dirs; + if (dir [cur_update_dir].nfiles >= files_per_dir) { + if ( num_dirs > 0 ) { + ++dnum %= num_dirs; + } else { + ++dnum; + } + } } if (gps_time_dirs) { @@ -445,8 +450,13 @@ if (gps_time_dirs) { dnum = cur_update_dir; // Switch to the next directory if current directory is full - if (dir [cur_update_dir].nfiles >= files_per_dir) - ++dnum %= num_dirs; + if (dir [cur_update_dir].nfiles >= files_per_dir) { + if ( num_dirs > 0 ) { + ++dnum %= num_dirs; + } else { + ++dnum; + } + } } _filename_dir (t, fname, dnum, framedt); -- GitLab