IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 22, 2012, 6:26:57 AM (14 years ago)
Author:
eugene
Message:

add function gfits_set_bintable_column_reformat (sets column type to match output table description); give normal TZERO and TSCALE defaults (0,1); handle NULL argument to gfits_print/modify string functions with an error not a crash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/libfits/header/F_print.c

    r28246 r33128  
    6565  /* string value.  Quotes must be at least 18 chars apart.  Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */
    6666  if (!strcmp (mode, "%s")) {
    67     strcpy (line, va_arg (argp, char *));
     67    char *ptr = va_arg (argp, char *);
     68    if (!ptr) goto invalid;
     69    strcpy (line, ptr);
    6870    line[68] = 0;
    6971    snprintf (string, 81, "%-8s= '%-18s' / %46s ", field, line, blank);
    7072    goto found_it;
    7173  }
     74
     75invalid:
     76  va_end (argp);
    7277  return (FALSE);
    7378
     
    7681  va_end (argp);
    7782  return (TRUE);
    78 
    7983}
    8084
     
    130134  if (!strcmp (mode, "%S")) {
    131135    /* we are forcing the entry to be <= 69 char long */
    132     strcpy (line, va_arg (argp, char *));
    133     line[71] = 0;
     136    char *ptr = va_arg (argp, char *);
     137    if (!ptr) goto invalid;
     138    bzero (line, 80);
     139    strncpy (line, ptr, 71);
    134140    snprintf (string, 81, "%-8s %-71s", field, line);
    135141  } 
     
    146152
    147153  /* can't write the comment in gfits_print - use gfits_modify */
    148   if (!strcmp (mode, "%C")) return (FALSE);
     154  if (!strcmp (mode, "%C")) goto invalid;
    149155
    150156  strncpy (p, string, 80);
     
    153159  return (TRUE);
    154160
     161invalid:
     162  va_end (argp);
     163  return (FALSE);
    155164}
Note: See TracChangeset for help on using the changeset viewer.