IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38526


Ignore:
Timestamp:
Jun 24, 2015, 6:55:47 AM (11 years ago)
Author:
eugene
Message:

replace sprintf with snprintf

Location:
branches/eam_branches/ipp-20150616/Ohana/src/libohana/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616/Ohana/src/libohana/src/config.c

    r38498 r38526  
    9191  uid = getuid();
    9292  gid = getgid();
    93   ALLOCATE (find, char, strlen(progname) + 32);
     93
     94  int Nchar = strlen(progname) + 32;
     95  ALLOCATE (find, char, Nchar);
    9496
    9597  /* look for progname.rc */
    96   sprintf (find, "%s.rc", progname);
     98  snprintf (find, Nchar, "%s.rc", progname);
    9799  status = stat (find, &filestat);
    98100  if (status == 0) {
     
    125127  if (home == (char *) NULL) { return ((char *) NULL); }
    126128  ALLOCATE (find, char, 1024);
    127   sprintf (find, "%s/.%src", home, progname);
     129  snprintf (find, 1024, "%s/.%src", home, progname);
    128130  status = stat (find, &filestat);
    129131  if (status == 0) {
     
    275277  va_start (argp, Nentry);
    276278
    277   ALLOCATE (tfield, char, strlen (field) + 3);
    278   sprintf (tfield, "\n%s", field);
     279  int Nchar = strlen (field) + 16;
     280  ALLOCATE (tfield, char, Nchar);
     281  snprintf (tfield, Nchar, "\n%s", field);
    279282
    280283  /* we search for Nentry matching fields,
  • branches/eam_branches/ipp-20150616/Ohana/src/libohana/src/findexec.c

    r38062 r38526  
    113113  /* check permission to write to backup file */
    114114  if (BACKUP) {
    115     ALLOCATE (filename, char, strlen(basefile) + 2);
    116     sprintf (filename, "%s~", basefile);
     115    int Nchar = strlen(basefile) + 16;
     116    ALLOCATE (filename, char, Nchar);
     117    snprintf (filename, Nchar, "%s~", basefile);
    117118    status = stat (filename, &filestat);
    118119    if (status == 0) { /* file exists, are permissions OK? */
     
    289290        e = strchr (c, ':');
    290291      }
    291       sprintf (name, "%s/%s", path, argv[0]);
     292      snprintf (name, 1024, "%s/%s", path, argv[0]);
    292293      status = check_file_exec (name);
    293294
     
    374375  int status, cmode;
    375376  struct stat filestat;
    376   char line[256];
     377  char line[1024];
    377378
    378379  status = stat (filename, &filestat);
    379380  if (status == 0) { /* file exists, make backup copy */
    380     sprintf (line, "cp %s %s~", filename, filename);
     381    snprintf (line, 1024, "cp %s %s~", filename, filename);
    381382    status = system (line);
    382383    if (status) {
     
    385386    }
    386387    cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
    387     sprintf (line, "%s~", filename);
     388    snprintf (line, 1024, "%s~", filename);
    388389    chmod (line, cmode);
    389390  }
  • branches/eam_branches/ipp-20150616/Ohana/src/libohana/src/glockfile.c

    r37807 r38526  
    152152    path = pathname (filename);
    153153    file = filebasename (filename);
    154     ALLOCATE (lockname, char, strlen (path) + strlen (file) + 10);
    155     sprintf (lockname, "%s/.%s.lck", path, file);
     154    int Nchar = strlen (path) + strlen (file) + 16;
     155    ALLOCATE (lockname, char, Nchar);
     156    snprintf (lockname, Nchar, "%s/.%s.lck", path, file);
    156157
    157158    status = stat (lockname, &filestat);
     
    261262    path = pathname (filename);
    262263    file = filebasename (filename);
    263     ALLOCATE (lockname, char, strlen (path) + strlen (file) + 10);
    264     sprintf (lockname, "%s/.%s.lck", path, file);
     264    int Nchar = strlen (path) + strlen (file) + 16;
     265    ALLOCATE (lockname, char, Nchar);
     266    snprintf (lockname, Nchar, "%s/.%s.lck", path, file);
    265267   
    266268    /* check for lockfile existance */
  • branches/eam_branches/ipp-20150616/Ohana/src/libohana/src/time.c

    r34088 r38526  
    141141      ALLOCATE (tmpline, char, 64);
    142142      gmt   = gmtime (&tsec);
    143       sprintf (tmpline, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]);
     143      snprintf (tmpline, 64, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]);
    144144      *second = ohana_date_to_sec (tmpline);
    145145      free (tmpline);
     
    251251  ALLOCATE (line, char, 64);
    252252  gmt   = gmtime (&second);
    253   sprintf (line, "%04d/%02d/%02d,%02d:%02d:%02d", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);
     253  snprintf (line, 64, "%04d/%02d/%02d,%02d:%02d:%02d", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);
    254254  return (line);
    255255
Note: See TracChangeset for help on using the changeset viewer.