Commit 84657f15 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

final pass at sprintf() buffer overflow prevention. also fix typo in previous commit

parent db510af5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -549,7 +549,7 @@ void NEB::open(char *file)
  else {
#ifdef LAMMPS_GZIP
    char gunzip[128];
    snprintf(gunz128,ip,"gzip -c -d %s",file);
    snprintf(gunzip,128,"gzip -c -d %s",file);

#ifdef _WIN32
    fp = _popen(gunzip,"rb");
+2 −2
Original line number Diff line number Diff line
@@ -1684,7 +1684,7 @@ void PairTlsph::coeff(int narg, char **arg) {
                } // end energy release rate failure criterion

                else {
                        sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]);
                  snprintf(str,128,"unknown *KEYWORD: %s", arg[ioffset]);
                  error->all(FLERR, str);
                }

+2 −2
Original line number Diff line number Diff line
@@ -1331,7 +1331,7 @@ void PairULSPH::coeff(int narg, char **arg) {
                        } // end *ARTIFICIAL_STRESS

                        else {
                                sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]);
                          snprintf(str,128, "unknown *KEYWORD: %s", arg[ioffset]);
                          error->all(FLERR, str);
                        }

+1 −1
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ void PairSMTBQ::read_file(char *file)
  fp = force->open_potential(file);
  if ( fp  == NULL ) {
    char str[128];
    sprintf(str,"Cannot open SMTBQ potential file %s",file);
    snprintf(str,128,"Cannot open SMTBQ potential file %s",file);
    error->one(FLERR,str);
  }

+1 −3
Original line number Diff line number Diff line
@@ -90,9 +90,7 @@ void DumpCFGUef::write_header(bigint n)
  if (atom->peri_flag) scale = atom->pdscale;
  else if (unwrapflag == 1) scale = UNWRAPEXPAND;

  char str[64];
  sprintf(str,"Number of particles = %s\n",BIGINT_FORMAT);
  fprintf(fp,str,n);
  fprintf(fp,"Number of particles = " BIGINT_FORMAT "\n",n);
  fprintf(fp,"A = %g Angstrom (basic length-scale)\n",scale);
  // in box[][] columns are cell edges
  // in H0, rows are cell edges