IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42116


Ignore:
Timestamp:
Mar 16, 2022, 4:21:02 PM (4 years ago)
Author:
eugene
Message:

gcc version 9.4 is more strict about input vs output buffer sizes and possible overruns

Location:
branches/eam_branches/ipp-20220316/Ohana/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/include/skycells.h

    r40528 r42116  
    3535
    3636/* globals which define database info / data sources (KEEP) */
    37 char   ImageCat[256];
     37char   ImageCat[512];
    3838char   GSCFILE[256];
    3939char   CATDIR[256];
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/ConfigInit_skycells.c

    r33719 r42116  
    66
    77  char *config, *file;
    8   char CatdirPhotcodeFile[256];
    9   char MasterPhotcodeFile[256];
     8  char CatdirPhotcodeFile[512];
     9  char MasterPhotcodeFile[512];
    1010
    1111  /*** load configuration info ***/
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/ReadStarsUKIRT.c

    r40520 r42116  
    6666  }
    6767
    68   char filter[80];
     68  char filter[50];
    6969  if (!gfits_scan (header, "FILTER", "%s", 1, filter)) {
    7070    fprintf (stderr, "missing FILTER\n");
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/fakeimage.c

    r40291 r42116  
    77  double Rmin, Rmax, Dmin, Dmax;
    88  double dX, dY, r, d;
    9   char chipname[80], chipdata[256], name[80];
     9  char chipname[16], chipdata[256], name[117];
    1010  char *config;
    1111  Image *image;
     
    6767  for (i = 0; i < Nchips; i++) {
    6868    /* this is the addstar name for the chip in the camera */
    69     sprintf (chipname, "CHIP.%03d", i);
     69    snprintf (chipname, 16, "CHIP.%03d", i);
    7070    ScanConfig (config, chipname, "%s", 0, chipdata);
    7171
     
    7474
    7575    /* this is the camera-specific name of a chip */
    76     sprintf (name, "%s.%s", rootname, chipname);
     76    snprintf (name, 117, "%s.%s", rootname, chipname);
    7777    strcpy (image[i+1].name, name);
    7878
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/getusno.c

    r38986 r42116  
    1010  float hours[100];
    1111  int start[100], number[100], *buffer, *buf;
    12   char filename[128];
     12  char filename[300];
    1313  FILE *f;
    1414  int iRA0, iRA1, iDEC0, iDEC1;
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/getusnob.c

    r38986 r42116  
    99  float hours[100];
    1010  int start[100], number[100], *buffer, *buf;
    11   char filename[128];
     11  char filename[300];
    1212  FILE *f;
    1313  double dec;
  • branches/eam_branches/ipp-20220316/Ohana/src/addstar/src/loadsupercos_plates.c

    r40291 r42116  
    7777    image[Nimage].dMcal     = 0.0;
    7878
    79     char photname[128];
    80     snprintf (photname, 128, "SCOS.%s.%s", emulsion, filterID);
     79    char photname[300];
     80    snprintf (photname, 300, "SCOS.%s.%s", emulsion, filterID);
    8181    image[Nimage].photcode = GetPhotcodeCodebyName (photname);
    8282    if (!image[Nimage].photcode) {
  • branches/eam_branches/ipp-20220316/Ohana/src/libdvo/src/coordops.c

    r42075 r42116  
    888888 
    889889  int OldAIPS;
    890   char csys[16], ctype[16];
     890  char csys[16], ctype[32];
    891891  double rotate, Lambda;
    892892
     
    906906    if (!strncmp (coords[0].ctype, "SLAT", 4)) strcpy (csys, "SLON");
    907907    if (!strcmp (csys, "NONE")) return (FALSE);
    908     snprintf (ctype, 16, "%s-%s", csys, &coords[0].ctype[5]);
     908    snprintf (ctype, 32, "%s-%s", csys, &coords[0].ctype[5]);
    909909    gfits_modify (header, "CTYPE1",   "%s",  1, ctype);
    910910  }   
  • branches/eam_branches/ipp-20220316/Ohana/src/libdvo/src/skyregion_gsc.c

    r41738 r42116  
    247247  int i;
    248248  double Rmin, Rmax, Dmin, Dmax;
    249   char temp[80], name[80];
     249  char temp[50], name[80];
    250250  SkyTable *band;
    251251  SkyRegion *regions;
  • branches/eam_branches/ipp-20220316/Ohana/src/libfits/header/F_create_H.c

    r34577 r42116  
    1212
    1313  ALLOCATE (header[0].buffer, char, NBYTES);
     14  bzero (header[0].buffer, NBYTES);
    1415
    15   for (i = 0; i < NBYTES; i++)
    16     header[0].buffer[i] = ' ';
    17   strncpy (header[0].buffer, "END", 3);
     16  for (i = 0; i < NBYTES; i++) header[0].buffer[i] = ' ';
     17  strcpy (header[0].buffer, "END");
    1818
    1919  gfits_modify_alt (header, "SIMPLE", "%t", 1, header[0].simple);
  • branches/eam_branches/ipp-20220316/Ohana/src/libfits/header/F_modify.c

    r38441 r42116  
    88  /* this function is extremely similar to gfits_print, except it allows for changing an existing field. */
    99
    10   char comment[82], string[82], data[82];
     10  // the output string needs to be long enough to keep the compiler from
     11  // complaining, even though the string cannot be more than 80 chars
     12  char comment[82], string[200], data[82];
    1113  char *p, *qe;
    1214  va_list argp;
     
    1416  va_start (argp, N);
    1517  bzero (data, 82);
    16   bzero (string, 82);
     18  bzero (string, 200);
    1719  bzero (comment, 82);
    1820
     
    5153
    5254  /* write the numeric modes */
    53   if (!strcmp (mode, "%d"))   { snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),                comment); goto found_it; }
    54   if (!strcmp (mode, "%ld"))  { snprintf (string, 81, "%-8s= %20ld / %-s ",   field, va_arg (argp, long),               comment); goto found_it; }
    55   if (!strcmp (mode, "%lld")) { snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long),          comment); goto found_it; }
    56   if (!strcmp (mode, "%Ld"))  { snprintf (string, 81, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long),          comment); goto found_it; }
    57   if (!strcmp (mode, "%u"))   { snprintf (string, 81, "%-8s= %20u / %-s ",    field, va_arg (argp, unsigned),           comment); goto found_it; }
    58   if (!strcmp (mode, "%lu"))  { snprintf (string, 81, "%-8s= %20lu / %-s ",   field, va_arg (argp, unsigned long),      comment); goto found_it; }
    59   if (!strcmp (mode, "%llu")) { snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
    60   if (!strcmp (mode, "%Lu"))  { snprintf (string, 81, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
    61   if (!strcmp (mode, "%hd"))  { snprintf (string, 81, "%-8s= %20d / %-s ",    field, va_arg (argp, int),                comment); goto found_it; }
    62   if (!strcmp (mode, "%f"))   { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    63   if (!strcmp (mode, "%lf"))  { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    64   if (!strcmp (mode, "%e"))   { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    65   if (!strcmp (mode, "%le"))  { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    66   if (!strcmp (mode, "%g"))   { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    67   if (!strcmp (mode, "%lg"))  { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),             comment); goto found_it; }
    68   if (!strcmp (mode, "%jd"))  { snprintf (string, 81, "%-8s= %20jd / %-s ",   field, va_arg (argp, intmax_t),           comment); goto found_it; }
     55  if (!strcmp (mode, "%d"))   { snprintf (string, 200, "%-8s= %20d / %-s ",    field, va_arg (argp, int),                       comment); goto found_it; }
     56  if (!strcmp (mode, "%ld"))  { snprintf (string, 200, "%-8s= %20ld / %-s ",   field, va_arg (argp, long),                      comment); goto found_it; }
     57  if (!strcmp (mode, "%lld")) { snprintf (string, 200, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long),                 comment); goto found_it; }
     58  if (!strcmp (mode, "%Ld"))  { snprintf (string, 200, "%-8s= %20lld / %-s ",  field, va_arg (argp, long long),                 comment); goto found_it; }
     59  if (!strcmp (mode, "%u"))   { snprintf (string, 200, "%-8s= %20u / %-s ",    field, va_arg (argp, unsigned),                  comment); goto found_it; }
     60  if (!strcmp (mode, "%lu"))  { snprintf (string, 200, "%-8s= %20lu / %-s ",   field, va_arg (argp, unsigned long),      comment); goto found_it; }
     61  if (!strcmp (mode, "%llu")) { snprintf (string, 200, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
     62  if (!strcmp (mode, "%Lu"))  { snprintf (string, 200, "%-8s= %20llu / %-s ",  field, va_arg (argp, unsigned long long), comment); goto found_it; }
     63  if (!strcmp (mode, "%hd"))  { snprintf (string, 200, "%-8s= %20d / %-s ",    field, va_arg (argp, int),               comment); goto found_it; }
     64  if (!strcmp (mode, "%f"))   { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     65  if (!strcmp (mode, "%lf"))  { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     66  if (!strcmp (mode, "%e"))   { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     67  if (!strcmp (mode, "%le"))  { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     68  if (!strcmp (mode, "%g"))   { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     69  if (!strcmp (mode, "%lg"))  { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double),            comment); goto found_it; }
     70  if (!strcmp (mode, "%jd"))  { snprintf (string, 200, "%-8s= %20jd / %-s ",   field, va_arg (argp, intmax_t),          comment); goto found_it; }
    6971
    7072  /* string value.  Quotes must be at least 8 chars apart */
     
    7375    if (!ptr) goto invalid;
    7476    strncpy (data, ptr, 68);
    75     snprintf (string, 81, "%-8s= '%-8s' / %-s ", field, data, comment);
     77    snprintf (string, 200, "%-8s= '%-8s' / %-s ", field, data, comment);
    7678    goto found_it;
    7779  }
     
    9496  /* this function is extremely similar to gfits_print, except it allows for changing an existing field. */
    9597
    96   char comment[82], string[82], data[82];
     98  char comment[82], string[200], data[82];
    9799  char *p, *qs, *qe;
    98100  va_list argp;
     
    100102  va_start (argp, N);
    101103  bzero (data, 82);
    102   bzero (string, 82);
    103104  bzero (comment, 82);
     105  bzero (string, 200);
    104106
    105107  if (mode[0] != '%') {
     
    139141  if (!strcmp (mode, "%t")) {
    140142    if (va_arg (argp, int))
    141       snprintf (string, 81, "%-8s= %18s T / %-s ", field, " ", comment);
     143      snprintf (string, 200, "%-8s= %18s T / %-s ", field, " ", comment);
    142144    else
    143       snprintf (string, 81, "%-8s= %18s F / %-s ", field, " ", comment);
     145      snprintf (string, 200, "%-8s= %18s F / %-s ", field, " ", comment);
    144146  }
    145147
     
    149151    if (!ptr) goto invalid;
    150152    strncpy (data, ptr, 71);
    151     snprintf (string, 81, "%-8s %-71s", field, data);
     153    snprintf (string, 200, "%-8s %-71s", field, data);
    152154  } 
    153155
     
    167169    strncpy (comment, ptr, 80);
    168170    gfits_pad_ending (comment, 0x20, 82);  /* comment must contain spaces to the end */
    169     snprintf (string, 81, "%-8s= %s / %-s", field, data, comment);
     171    snprintf (string, 200, "%-8s= %s / %-s", field, data, comment);
    170172    /* this will keep the original line, but truncate the comment */
    171173  }
  • branches/eam_branches/ipp-20220316/Ohana/src/libfits/header/F_print.c

    r34577 r42116  
    88
    99  static char blank[] = " ";
    10   char string[82], line[80];
     10  char string[200], line[80];
    1111  char *p;
    1212  va_list argp; 
     
    4646
    4747  /* write the numeric modes */
    48   if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
    49   if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); goto found_it; }
    50   if (!strcmp (mode, "%lld")){ snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
    51   if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
    52   if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); goto found_it; }
    53   if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); goto found_it; }
    54   if (!strcmp (mode, "%llu")){ snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
    55   if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
    56   if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
    57   if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    58   if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    59   if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    60   if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    61   if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    62   if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    63   if (!strcmp (mode, "%jd")) { snprintf (string, 81, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); goto found_it; }
     48  if (!strcmp (mode, "%d"))  { snprintf (string, 200, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
     49  if (!strcmp (mode, "%ld")) { snprintf (string, 200, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); goto found_it; }
     50  if (!strcmp (mode, "%lld")){ snprintf (string, 200, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
     51  if (!strcmp (mode, "%Ld")) { snprintf (string, 200, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
     52  if (!strcmp (mode, "%u"))  { snprintf (string, 200, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); goto found_it; }
     53  if (!strcmp (mode, "%lu")) { snprintf (string, 200, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); goto found_it; }
     54  if (!strcmp (mode, "%llu")){ snprintf (string, 200, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
     55  if (!strcmp (mode, "%Lu")) { snprintf (string, 200, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
     56  if (!strcmp (mode, "%hd")) { snprintf (string, 200, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
     57  if (!strcmp (mode, "%f"))  { snprintf (string, 200, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     58  if (!strcmp (mode, "%lf")) { snprintf (string, 200, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     59  if (!strcmp (mode, "%e"))  { snprintf (string, 200, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     60  if (!strcmp (mode, "%le")) { snprintf (string, 200, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     61  if (!strcmp (mode, "%g"))  { snprintf (string, 200, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     62  if (!strcmp (mode, "%lg")) { snprintf (string, 200, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     63  if (!strcmp (mode, "%jd")) { snprintf (string, 200, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); goto found_it; }
    6464
    6565  /* string value.  Quotes must be at least 8 chars apart.  Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */
     
    6969    strcpy (line, ptr);
    7070    line[68] = 0;
    71     snprintf (string, 81, "%-8s= '%-8s' / %46s ", field, line, blank);
     71    snprintf (string, 200, "%-8s= '%-8s' / %46s ", field, line, blank);
    7272    goto found_it;
    7373  }
     
    8989
    9090  static char blank[] = " ";
    91   char string[82], line[80];
     91  char string[200], line[80];
    9292  char *p, a;
    9393  va_list argp; 
     
    126126    a = va_arg (argp, int);
    127127    if (a == 1)
    128       snprintf (string, 81, "%-8s= %18s T / %46s ", field, blank, blank);
     128      snprintf (string, 200, "%-8s= %18s T / %46s ", field, blank, blank);
    129129    else
    130       snprintf (string, 81, "%-8s= %18s F / %46s ", field, blank, blank);
     130      snprintf (string, 200, "%-8s= %18s F / %46s ", field, blank, blank);
    131131  }
    132132
     
    138138    bzero (line, 80);
    139139    strncpy (line, ptr, 71);
    140     snprintf (string, 81, "%-8s %-71s", field, line);
     140    snprintf (string, 200, "%-8s %-71s", field, line);
    141141  } 
    142142
  • branches/eam_branches/ipp-20220316/Ohana/src/libfits/table/F_create_TH.c

    r38989 r42116  
    1717  myAssert (!header->buffer, "failed to init header or free buffer?");
    1818  ALLOCATE (header[0].buffer, char, NBYTES);
     19  bzero (header[0].buffer, NBYTES);
    1920 
    20   for (i = 0; i < NBYTES; i++)
    21   header[0].buffer[i] = ' ';
    22   strncpy (header[0].buffer, "END", 3);
     21  for (i = 0; i < NBYTES; i++) header[0].buffer[i] = ' ';
     22  strcpy (header[0].buffer, "END");
    2323 
    2424  gfits_modify (header, "XTENSION", "%s", 1, type);
  • branches/eam_branches/ipp-20220316/Ohana/src/libohana/src/findexec.c

    r39457 r42116  
    259259
    260260  int i, N, done, status;
    261   char *c, *e, *dir, path[1024], name[1024];
     261  char *c, *e, *dir, path[1024], name[1280];
    262262
    263263  /* if given an absolute or relative path, use it */
     
    295295        e = strchr (c, ':');
    296296      }
    297       snprintf (name, 1024, "%s/%s", path, argv[0]);
     297      snprintf (name, 1080, "%s/%s", path, argv[0]);
    298298      status = check_file_exec (name);
    299299
Note: See TracChangeset for help on using the changeset viewer.