IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39395


Ignore:
Timestamp:
Feb 26, 2016, 6:20:45 AM (10 years ago)
Author:
eugene
Message:

trying to catch some (possible) stack and heap overflow errors: adding padding to allocated config regions, using scan_line_maxlen

Location:
trunk/Ohana/src/libdvo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/src/HostTable.c

    r39319 r39395  
    124124
    125125    // XXXX use this for safety: int status = scan_line_maxlen (f, line, 1024);
    126     int status = scan_line (f, line);
     126    int status = scan_line_maxlen (f, line, 1024);
    127127    if (status == EOF) break;
    128128
     
    702702int HostTableTestHost (SkyRegion *region, int hostID) {
    703703
     704  myAssert (region, "oops");
     705
    704706  // if hostID is not set, then we are not in a remote client
    705707  if (!hostID) return TRUE;
  • trunk/Ohana/src/libdvo/src/LoadPhotcodesText.c

    r37035 r39395  
    1414  return (value);
    1515}
     16
     17# define MAX_LINE_LENGTH 1024
     18# define MAX_WORD_LENGTH 64
    1619
    1720/* load the text photcode table */
     
    2629  int code;
    2730  char *c;
    28   char line[256], **c1_names, **c2_names, **eq_names;
    29   char name[32], type[32], Zero[32], Airmass[32], Offset[32];
    30   char C1[32], C2[32], Slope[32], Color[32], Primary[32];
    31   char astromErrSys[32], astromErrScale[32], astromErrMagScale[32], photomErrSys[32];
    32   char astromPoorMask[32], astromBadMask[32], photomPoorMask[32], photomBadMask[32];
     31  char line[MAX_LINE_LENGTH], **c1_names, **c2_names, **eq_names;
     32  char name[MAX_WORD_LENGTH], type[MAX_WORD_LENGTH], Zero[MAX_WORD_LENGTH], Airmass[MAX_WORD_LENGTH], Offset[MAX_WORD_LENGTH];
     33  char C1[MAX_WORD_LENGTH], C2[MAX_WORD_LENGTH], Slope[MAX_WORD_LENGTH], Color[MAX_WORD_LENGTH], Primary[MAX_WORD_LENGTH];
     34  char astromErrSys[MAX_WORD_LENGTH], astromErrScale[MAX_WORD_LENGTH], astromErrMagScale[MAX_WORD_LENGTH], photomErrSys[MAX_WORD_LENGTH];
     35  char astromPoorMask[MAX_WORD_LENGTH], astromBadMask[MAX_WORD_LENGTH], photomPoorMask[MAX_WORD_LENGTH], photomBadMask[MAX_WORD_LENGTH];
    3336
    3437  table = GetPhotcodeTable ();
     
    5962  ALLOCATE (c2_names, char *,   NPHOTCODE);
    6063
    61   while (scan_line (f, line) != EOF) {
     64  while (scan_line_maxlen (f, line, MAX_LINE_LENGTH) != EOF) {
    6265    for (c = line; isspace (*c); c++);
    6366    if (*c == '#') continue;
  • trunk/Ohana/src/libdvo/src/RegionHostTable.c

    r38553 r39395  
    5858}
    5959
     60# define MAX_LINE_LENGTH 1024
    6061RegionHostTable *RegionHostTableLoad (char *catdir, char *rootname) {
    6162
     
    9596  for (Nline = 0; TRUE; Nline ++) {
    9697    int ID;
    97     char tmphost[1024];
    98     char line[1024];
    99 
    100     // XXXX use this for safety: int status = scan_line_maxlen (f, line, 1024);
    101     int status = scan_line (f, line);
     98    char tmphost[MAX_LINE_LENGTH];
     99    char line[MAX_LINE_LENGTH];
     100
     101    int status = scan_line_maxlen (f, line, MAX_LINE_LENGTH);
    102102    if (status == EOF) break;
    103103
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r39380 r39395  
    999999    catalog[0].measure = NULL;
    10001000  }
     1001  if (catalog[0].measureT) {
     1002    free (catalog[0].measureT);
     1003  }
    10011004  if (catalog[0].missing) {
    10021005    free (catalog[0].missing);
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r39359 r39395  
    445445  if (!gfits_scan (&catalog[0].header, "NLENSOBJ",  OFF_T_FMT, 1,  &Nlensobj))  Nlensobj  = 0;
    446446  if (!gfits_scan (&catalog[0].header, "NSTARPAR",  OFF_T_FMT, 1,  &Nstarpar))  Nstarpar  = 0;
    447   if (!gfits_scan (&catalog[0].header, "NGALPHOT", OFF_T_FMT, 1,  &Ngalphot)) Ngalphot = 0;
     447  if (!gfits_scan (&catalog[0].header, "NGALPHOT",  OFF_T_FMT, 1,  &Ngalphot))  Ngalphot = 0;
    448448
    449449  /* the OBJID is a counter that uniquely defines an average entry and never changes.  if
Note: See TracChangeset for help on using the changeset viewer.