Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utils.c

    r20 r29  
    189189}
    190190
    191 int sh_util_hidesetup(char * c)
     191int sh_util_hidesetup(const char * c)
    192192{
    193193  int i;
     
    205205  SL_ENTER(_("sh_util_strdup"));
    206206
    207   if (str != NULL)
    208     {
    209       len = sl_strlen(str);
    210       p   = SH_ALLOC (len + 1);
    211       (void) sl_strlcpy (p, str, len+1);
    212     }
     207  SH_VALIDATE_NE(str, NULL);
     208
     209  len = sl_strlen(str);
     210  p   = SH_ALLOC (len + 1);
     211  (void) sl_strlcpy (p, str, len+1);
     212
    213213  SL_RETURN( p, _("sh_util_strdup"));
    214214}
     
    224224  ret = *str;
    225225
    226   if (ret == NULL) {
    227     SL_RETURN(ret, _("sh_util_strsep"));
    228   }
     226  SH_VALIDATE_NE(ret, NULL);
    229227
    230228  for (c = *str; *c != '\0'; c++) {
     
    646644static int sigtype = TYPE_HMAC;
    647645
    648 int sh_util_sigtype (char * c)
     646int sh_util_sigtype (const char * c)
    649647{
    650648  SL_ENTER(_("sh_util_sigtype"));
     
    957955  char * key;
    958956  char * path;
    959   char * outpath;
     957  char * outpath = NULL;
    960958  unsigned char * image = NULL;
    961959  long s = 0;
     
    963961  long ii, k = 0;
    964962  UINT32    * h1;
    965   char * new;
     963  char * new = NULL;
    966964
    967965  if (0 != sl_is_suid())
     
    999997      fprintf(stderr,
    1000998              _("ERROR: no path to executable given\n Argument must be 'key@path'\n"));
     999      free(new);
    10011000      _exit (EXIT_FAILURE);
    10021001      /*@notreached@*/
     
    10051004  else
    10061005    path = &new[j];
     1006
     1007  len = strlen(path) + 1 + 4;
    10071008  /*@-usedef@*/
    1008   if (NULL == (outpath = malloc(strlen(path) + 1 + 4)))
     1009  if (NULL == (outpath = malloc(len)))
    10091010    goto bail_mem;
    10101011  /*@-usedef@*/
    1011   /*@-bufferoverflowhigh@*/
    1012   sprintf (outpath, _("%s.out"), path);               /* known to fit  */
    1013   /*@+bufferoverflowhigh@*/
     1012  sl_snprintf (outpath, len, _("%s.out"), path);
    10141013
    10151014  fp = sl_open_read(path, SL_NOPRIV);
     
    10181017      fprintf(stderr,
    10191018              _("ERROR: cannot open %s for read (errnum = %ld)\n"), path, fp);
     1019      free(new); free (outpath);
    10201020      _exit (EXIT_FAILURE);
    10211021      /*@notreached@*/
     
    10281028      fprintf(stderr,
    10291029              _("ERROR: cannot open %s (errnum = %ld)\n"), outpath, fout);
     1030      free(new); free (outpath);
    10301031      _exit (EXIT_FAILURE);
    10311032      /*@notreached@*/
     
    10681069          (void) sl_close (fout);
    10691070          printf(_("new file %s written\n"), outpath);
     1071          free(new); free (outpath); free(image);
    10701072          _exit (EXIT_SUCCESS);
    10711073          /*@notreached@*/
     
    10761078  fprintf(stderr,
    10771079          _("ERROR: old key not found\n"));
     1080  free(new); free (outpath); free(image);
    10781081  _exit (EXIT_FAILURE);
    10791082  /*@notreached@*/
     
    10841087  fprintf(stderr,
    10851088          _("ERROR: out of memory\n"));
     1089  if (new) free(new);
     1090  if (outpath) free (outpath);
     1091  if (image) free (image);
    10861092  _exit (EXIT_FAILURE);
    10871093  /*@notreached@*/
     
    13291335static unsigned char sh_obscure_index[256];
    13301336
    1331 int sh_util_obscure_ok (char * str)
     1337int sh_util_obscure_ok (const char * str)
    13321338{
    13331339  unsigned long   i;
    1334   char * endptr = str;
    1335 
    1336   SL_ENTER(_("sh_util_obscure_ex"));
     1340  char * endptr = NULL;
     1341
     1342  SL_ENTER(_("sh_util_obscure_ok"));
    13371343
    13381344  if (0 == sl_strncmp("all", str, 3))
     
    13421348          sh_obscure_index[i] = (unsigned char)1;
    13431349        }
    1344       SL_RETURN(0, _("sh_util_obscure_ex"));
     1350      SL_RETURN(0, _("sh_util_obscure_ok"));
    13451351    }
    13461352
     
    13491355      sh_obscure_index[i] = (unsigned char)0;
    13501356    }
     1357
     1358  i = strtoul (str, &endptr, 0);
     1359  if (i > 255)
     1360    {
     1361      SL_RETURN(-1, _("sh_util_obscure_ok"));
     1362    }
     1363  sh_obscure_index[i] = (unsigned char)1;
     1364  if (*endptr == ',')
     1365    ++endptr;
    13511366
    13521367  while (*endptr != '\0')
     
    13551370      if (i > 255)
    13561371        {
    1357           SL_RETURN(-1, _("sh_util_obscure_ex"));
     1372          SL_RETURN(-1, _("sh_util_obscure_ok"));
    13581373        }
    13591374      sh_obscure_index[i] = (unsigned char)1;
     
    13611376        ++endptr;
    13621377    }
    1363   SL_RETURN(0, _("sh_util_obscure_ex"));
     1378  SL_RETURN(0, _("sh_util_obscure_ok"));
    13641379}
    13651380
    13661381int sh_util_obscurename (ShErrLevel level, char * name_orig, int flag)
    13671382{
    1368   char * name = name_orig;
     1383  unsigned char * name = (unsigned char *) name_orig;
    13691384  char * safe;
    13701385  unsigned int i;
     
    13781393  while (*name != '\0')
    13791394    {
    1380       if ( (*name) == '"'  || (*name) == '\t' ||
     1395      if ( (*name) >  0x7F || (*name) == '"'  || (*name) == '\t' ||
    13811396           (*name) == '\b' || (*name) == '\f' ||
    13821397           (*name) == '\n' || (*name) == '\r' ||
     
    15621577    } else if (!isgraph ((int) *p)) {    /* not printable    */
    15631578      /*@-bufferoverflowhigh -formatconst@*/
     1579      /* flawfinder: ignore */
    15641580      sprintf(oct, format, '\\',                 /* known to fit  */
    15651581              (unsigned char) *p);
Note: See TracChangeset for help on using the changeset viewer.