IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40501


Ignore:
Timestamp:
Jul 6, 2018, 1:42:20 PM (8 years ago)
Author:
eugene
Message:

give enough space to avoid running out of room in snprintf, if possible

Location:
trunk/Ohana/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/imregister/detrend/altpath.c

    r34088 r40501  
    77  off_t i, j, n, Nlist;
    88  off_t *list;
    9   char *dBPath, infile[256], outfile[256], line[1024];
     9  char *dBPath, infile[512], outfile[512], line[1100];
    1010  struct stat statbuf;
    1111
     
    2828      i = list[j];
    2929      for (n = 0; n < NDetrendAltDB; n++) {
    30         sprintf (infile, "%s/%s", dBPath, image[i].filename);
    31         sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename);
     30        snprintf (infile, 512, "%s/%s", dBPath, image[i].filename);
     31        snprintf (outfile, 512, "%s/%s", DetrendAltDB[n], image[i].filename);
    3232        status = ckpathname (outfile);
    3333        if (!status) {
     
    3535          continue;
    3636        }
    37         sprintf (line, "cp %s %s", infile, outfile);
     37        snprintf (line, 1100, "cp %s %s", infile, outfile);
    3838        fprintf (stderr, "%s\n", line);
    3939        status = system (line);
     
    7373      image[i].altpath = FALSE;
    7474      for (n = 0; n < NDetrendAltDB; n++) {
    75         sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename);
    76         sprintf (line, "rm %s", outfile);
     75        snprintf (outfile, 512, "%s/%s", DetrendAltDB[n], image[i].filename);
     76        snprintf (line, 1100, "rm %s", outfile);
    7777        fprintf (stderr, "%s\n", line);
    7878        status = system (line);
     
    104104      found = TRUE;
    105105      for (n = 0; found && (n < NDetrendAltDB); n++) {
    106         sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename);
     106        snprintf (outfile, 512, "%s/%s", DetrendAltDB[n], image[i].filename);
    107107        status = stat (outfile, &statbuf);
    108108        fprintf (stderr, "checking for %s, status is %d\n", outfile, status);
  • trunk/Ohana/src/imregister/detrend/db_names.c

    r6674 r40501  
    5252 
    5353  int status;
    54   char line[256];
     54  char line[512];
    5555
    5656  if (output.verbose) fprintf (stderr, "deleting %s\n", item[0].filename);
    57   sprintf (line, "mv -f %s/%s %s", dBPath, item[0].filename, dBTrash);
     57  snprintf (line, 512, "mv -f %s/%s %s", dBPath, item[0].filename, dBTrash);
    5858  status = system (line);
    5959  if (status) fprintf (stderr, "trouble moving %s to trash (%s)\n", item[0].filename, dBTrash);
  • trunk/Ohana/src/imregister/detrend/output.c

    r38441 r40501  
    193193int PrintSubset (DetReg *detdata, Match *match, off_t Nmatch) {
    194194 
    195   char *dBPath, *Path, *typestr, *filtstr, filename[128];
     195  char *dBPath, *Path, *typestr, *filtstr, filename[512];
    196196  char *timestr, *modestr, *ccdstr, ccdinfo[16], ccdformat[16];
    197197  off_t i, j;
     
    239239    /* output mode (Select vs List) */
    240240    if (output.Chipname && criteria[0].CCDSelect && detdata[i].mode == M_MEF) {
    241       snprintf (filename, 128, "%s[%s]", detdata[i].filename, ccds[criteria[0].CCD]);
     241      snprintf (filename, 512, "%s[%s]", detdata[i].filename, ccds[criteria[0].CCD]);
    242242    } else {
    243243      strcpy (filename, detdata[i].filename);
  • trunk/Ohana/src/kapa2/include/constants.h

    r40419 r40501  
    1111
    1212# define NCHANNELS 10
     13# define LONG_LINE_LENGTH 1024
    1314
    1415# define PAD1  3
  • trunk/Ohana/src/kapa2/include/structures.h

    r40419 r40501  
    6464  int      x, y, dx, dy;   /* position and size */
    6565  char    *label;          /* label on TextLine */
    66   char     text[1024];     /* words of TextLine */
    67   char     old_text[1024]; /* words of TextLine */
     66  char     text[LONG_LINE_LENGTH];     /* words of TextLine */
     67  char     old_text[LONG_LINE_LENGTH]; /* words of TextLine */
    6868  int      outline;        /* draw an outline?  */
    6969  int      cursor;         /* location of cursor (if selected) */
     
    179179  double   start, slope;   /* zero, range for cmap to pixels */
    180180  Coords   coords;
    181   char     file[1024];     /* name of file */
    182   char     name[1024];     /* name of buffer */
     181  char     file[LONG_LINE_LENGTH];     /* name of file */
     182  char     name[LONG_LINE_LENGTH];     /* name of buffer */
    183183} KapaImageChannel;
    184184
  • trunk/Ohana/src/kapa2/src/UpdateStatusBox.c

    r37807 r40501  
    11# include "Ximage.h"
    22
     3# define MY_LONG_LINE (LONG_LINE_LENGTH + 128)
    34void UpdateStatusBox (Graphic *graphic, KapaImageWidget *image, double x, double y, double z, int mode) {
    45
    56  int textpad;
    67  double ra, dec;
    7   char line[100];
     8  char line[MY_LONG_LINE];
    89
    910  XY_to_RD (&ra, &dec, x, y, &image[0].image[0].coords);
     
    1920                    image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy);
    2021 
    21     bzero (line, 100);
    22     snprintf (line, 100, "(%d x %d) @ %d   ch: %d                                     ",
     22    bzero (line, MY_LONG_LINE);
     23    snprintf (line, MY_LONG_LINE, "(%d x %d) @ %d   ch: %d                                     ",
    2324              image[0].picture.dx, image[0].picture.dy, image[0].picture.expand, image[0].currentChannel+1);
    2425    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    2526                 image[0].text_x + PAD1, image[0].text_y + 4*textpad + 4*PAD1, line, 25);
    2627   
    27     bzero (line, 100);
    28     snprintf (line, 100, "%-25s", image[0].image[0].file);
     28    bzero (line, MY_LONG_LINE);
     29    snprintf (line, MY_LONG_LINE, "%-25s", image[0].image[0].file);
    2930    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    3031                 image[0].text_x + PAD1, image[0].text_y + 5*textpad + 5*PAD1, line, strlen(line));
    3132   
    32     bzero (line, 100);
    33     snprintf (line, 100, "(%s)                                          ", image[0].image[0].name);
     33    bzero (line, MY_LONG_LINE);
     34    snprintf (line, MY_LONG_LINE, "(%s)                                          ", image[0].image[0].name);
    3435    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    3536                 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
     
    4243    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    4344  }
    44   bzero (line, 100);
     45  bzero (line, MY_LONG_LINE);
    4546
    4647  if (image[0].HexValue) {
    47       snprintf (line, 100, "%04x", (int) z);
     48      snprintf (line, MY_LONG_LINE, "%04x", (int) z);
    4849  } else {
    49       snprintf (line, 100, "%22.3f", z);
     50      snprintf (line, MY_LONG_LINE, "%22.3f", z);
    5051  }
    5152  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    5253               image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, line, strlen(line));
    5354 
    54   bzero (line, 100);
    55   snprintf (line, 100, "%10.2f %10.2f", x, y);
     55  bzero (line, MY_LONG_LINE);
     56  snprintf (line, MY_LONG_LINE, "%10.2f %10.2f", x, y);
    5657  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    5758               image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line));
    5859 
    59   bzero (line, 100);
     60  bzero (line, MY_LONG_LINE);
    6061  if (image[0].DecimalDegrees) {
    61     snprintf (line, 100, "%10.6f %10.6f", ra, dec);
     62    snprintf (line, MY_LONG_LINE, "%10.6f %10.6f", ra, dec);
    6263  } else {
    63     hh_hms (line, ra, dec, ':', 100);
     64    hh_hms (line, ra, dec, ':', MY_LONG_LINE);
    6465  }
    6566
Note: See TracChangeset for help on using the changeset viewer.