Skip to content

Fix format overflow on gcc 8 in coinj.c

Description

Fix format overflow on gcc 8 in coinj.c.

Fixes this error:

In file included from /opt/local/lib/gcc8/gcc/x86_64-apple-darwin19/8.4.0/include-fixed/stdio.h:421,
                 from coinj.c:20:
coinj.c: In function 'main':
coinj.c:380:29: error: '%s' directive writing up to 29 bytes into a region of size between 0 and 1014 [-Werror=format-overflow=]
         sprintf(outfilename,"%s%s%i_CBC_%s_%i_%s_%s.txt",outputpath,"/",inj_epoch.gpsSeconds,massBin,inj_num,injtype,det_name);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                     ~~~~~~~
coinj.c:380:9: note: '__builtin___sprintf_chk' output between 16 and 1077 bytes into a destination of size 1024
         sprintf(outfilename,"%s%s%i_CBC_%s_%i_%s_%s.txt",outputpath,"/",inj_epoch.gpsSeconds,massBin,inj_num,injtype,det_name);
         ^~~~~~~
coinj.c:434:23: error: '_HWINJ_STRAIN-' directive writing 14 bytes into a region of size between 0 and 1017 [-Werror=format-overflow=]
         sprintf(fname,"%s%s%s-INSP%i_HWINJ_STRAIN-%i-%i.gwf",outputpath,"/",det_name, inj_num, inj_epoch.gpsSeconds, (UINT4)injLength);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coinj.c:434:9: note: '__builtin___sprintf_chk' output between 31 and 1059 bytes into a destination of size 1024
         sprintf(fname,"%s%s%s-INSP%i_HWINJ_STRAIN-%i-%i.gwf",outputpath,"/",det_name, inj_num, inj_epoch.gpsSeconds, (UINT4)injLength);
         ^~~~~~~

API Changes and Justification

Backwards Compatible Changes

  • This change introduces no API changes
  • This change adds new API calls

Backwards Incompatible Changes

  • This change modifies an existing API
  • This change removes an existing API

If any of the Backwards Incompatible check boxes are ticked please provide a justification why this change is necessary and why it needs to be done in a backwards incompatible way.

Review Status

This is a trivial error handling bug fix, so I don't think that it requires review.

Merge request reports

Loading