Changeset 22 for trunk/src/sh_utils.c


Ignore:
Timestamp:
Feb 23, 2006, 12:03:58 AM (19 years ago)
Author:
rainer
Message:

Minor code revisions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utils.c

    r20 r22  
    189189}
    190190
    191 int sh_util_hidesetup(char * c)
     191int sh_util_hidesetup(const char * c)
    192192{
    193193  int i;
     
    646646static int sigtype = TYPE_HMAC;
    647647
    648 int sh_util_sigtype (char * c)
     648int sh_util_sigtype (const char * c)
    649649{
    650650  SL_ENTER(_("sh_util_sigtype"));
     
    957957  char * key;
    958958  char * path;
    959   char * outpath;
     959  char * outpath = NULL;
    960960  unsigned char * image = NULL;
    961961  long s = 0;
     
    963963  long ii, k = 0;
    964964  UINT32    * h1;
    965   char * new;
     965  char * new = NULL;
    966966
    967967  if (0 != sl_is_suid())
     
    999999      fprintf(stderr,
    10001000              _("ERROR: no path to executable given\n Argument must be 'key@path'\n"));
     1001      free(new);
    10011002      _exit (EXIT_FAILURE);
    10021003      /*@notreached@*/
     
    10051006  else
    10061007    path = &new[j];
     1008
     1009  len = strlen(path) + 1 + 4;
    10071010  /*@-usedef@*/
    1008   if (NULL == (outpath = malloc(strlen(path) + 1 + 4)))
     1011  if (NULL == (outpath = malloc(len)))
    10091012    goto bail_mem;
    10101013  /*@-usedef@*/
    1011   /*@-bufferoverflowhigh@*/
    1012   sprintf (outpath, _("%s.out"), path);               /* known to fit  */
    1013   /*@+bufferoverflowhigh@*/
     1014  sl_snprintf (outpath, len, _("%s.out"), path);
    10141015
    10151016  fp = sl_open_read(path, SL_NOPRIV);
     
    10181019      fprintf(stderr,
    10191020              _("ERROR: cannot open %s for read (errnum = %ld)\n"), path, fp);
     1021      free(new); free (outpath);
    10201022      _exit (EXIT_FAILURE);
    10211023      /*@notreached@*/
     
    10281030      fprintf(stderr,
    10291031              _("ERROR: cannot open %s (errnum = %ld)\n"), outpath, fout);
     1032      free(new); free (outpath);
    10301033      _exit (EXIT_FAILURE);
    10311034      /*@notreached@*/
     
    10681071          (void) sl_close (fout);
    10691072          printf(_("new file %s written\n"), outpath);
     1073          free(new); free (outpath); free(image);
    10701074          _exit (EXIT_SUCCESS);
    10711075          /*@notreached@*/
     
    10761080  fprintf(stderr,
    10771081          _("ERROR: old key not found\n"));
     1082  free(new); free (outpath); free(image);
    10781083  _exit (EXIT_FAILURE);
    10791084  /*@notreached@*/
     
    10841089  fprintf(stderr,
    10851090          _("ERROR: out of memory\n"));
     1091  if (new) free(new);
     1092  if (outpath) free (outpath);
     1093  if (image) free (image);
    10861094  _exit (EXIT_FAILURE);
    10871095  /*@notreached@*/
     
    13291337static unsigned char sh_obscure_index[256];
    13301338
    1331 int sh_util_obscure_ok (char * str)
     1339int sh_util_obscure_ok (const char * str)
    13321340{
    13331341  unsigned long   i;
    1334   char * endptr = str;
     1342  char * endptr = NULL;
    13351343
    13361344  SL_ENTER(_("sh_util_obscure_ex"));
     
    13491357      sh_obscure_index[i] = (unsigned char)0;
    13501358    }
     1359
     1360  i = strtoul (str, &endptr, 0);
     1361  if (i > 255)
     1362    {
     1363      SL_RETURN(-1, _("sh_util_obscure_ex"));
     1364    }
     1365  sh_obscure_index[i] = (unsigned char)1;
     1366  if (*endptr == ',')
     1367    ++endptr;
    13511368
    13521369  while (*endptr != '\0')
     
    15621579    } else if (!isgraph ((int) *p)) {    /* not printable    */
    15631580      /*@-bufferoverflowhigh -formatconst@*/
     1581      /* flawfinder: ignore */
    15641582      sprintf(oct, format, '\\',                 /* known to fit  */
    15651583              (unsigned char) *p);
Note: See TracChangeset for help on using the changeset viewer.