Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utils.c

    r29 r20  
    189189}
    190190
    191 int sh_util_hidesetup(const char * c)
     191int sh_util_hidesetup(char * c)
    192192{
    193193  int i;
     
    205205  SL_ENTER(_("sh_util_strdup"));
    206206
    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 
     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    }
    213213  SL_RETURN( p, _("sh_util_strdup"));
    214214}
     
    224224  ret = *str;
    225225
    226   SH_VALIDATE_NE(ret, NULL);
     226  if (ret == NULL) {
     227    SL_RETURN(ret, _("sh_util_strsep"));
     228  }
    227229
    228230  for (c = *str; *c != '\0'; c++) {
     
    644646static int sigtype = TYPE_HMAC;
    645647
    646 int sh_util_sigtype (const char * c)
     648int sh_util_sigtype (char * c)
    647649{
    648650  SL_ENTER(_("sh_util_sigtype"));
     
    955957  char * key;
    956958  char * path;
    957   char * outpath = NULL;
     959  char * outpath;
    958960  unsigned char * image = NULL;
    959961  long s = 0;
     
    961963  long ii, k = 0;
    962964  UINT32    * h1;
    963   char * new = NULL;
     965  char * new;
    964966
    965967  if (0 != sl_is_suid())
     
    997999      fprintf(stderr,
    9981000              _("ERROR: no path to executable given\n Argument must be 'key@path'\n"));
    999       free(new);
    10001001      _exit (EXIT_FAILURE);
    10011002      /*@notreached@*/
     
    10041005  else
    10051006    path = &new[j];
    1006 
    1007   len = strlen(path) + 1 + 4;
    10081007  /*@-usedef@*/
    1009   if (NULL == (outpath = malloc(len)))
     1008  if (NULL == (outpath = malloc(strlen(path) + 1 + 4)))
    10101009    goto bail_mem;
    10111010  /*@-usedef@*/
    1012   sl_snprintf (outpath, len, _("%s.out"), path);
     1011  /*@-bufferoverflowhigh@*/
     1012  sprintf (outpath, _("%s.out"), path);               /* known to fit  */
     1013  /*@+bufferoverflowhigh@*/
    10131014
    10141015  fp = sl_open_read(path, SL_NOPRIV);
     
    10171018      fprintf(stderr,
    10181019              _("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);
    10311030      _exit (EXIT_FAILURE);
    10321031      /*@notreached@*/
     
    10691068          (void) sl_close (fout);
    10701069          printf(_("new file %s written\n"), outpath);
    1071           free(new); free (outpath); free(image);
    10721070          _exit (EXIT_SUCCESS);
    10731071          /*@notreached@*/
     
    10781076  fprintf(stderr,
    10791077          _("ERROR: old key not found\n"));
    1080   free(new); free (outpath); free(image);
    10811078  _exit (EXIT_FAILURE);
    10821079  /*@notreached@*/
     
    10871084  fprintf(stderr,
    10881085          _("ERROR: out of memory\n"));
    1089   if (new) free(new);
    1090   if (outpath) free (outpath);
    1091   if (image) free (image);
    10921086  _exit (EXIT_FAILURE);
    10931087  /*@notreached@*/
     
    13351329static unsigned char sh_obscure_index[256];
    13361330
    1337 int sh_util_obscure_ok (const char * str)
     1331int sh_util_obscure_ok (char * str)
    13381332{
    13391333  unsigned long   i;
    1340   char * endptr = NULL;
    1341 
    1342   SL_ENTER(_("sh_util_obscure_ok"));
     1334  char * endptr = str;
     1335
     1336  SL_ENTER(_("sh_util_obscure_ex"));
    13431337
    13441338  if (0 == sl_strncmp("all", str, 3))
     
    13481342          sh_obscure_index[i] = (unsigned char)1;
    13491343        }
    1350       SL_RETURN(0, _("sh_util_obscure_ok"));
     1344      SL_RETURN(0, _("sh_util_obscure_ex"));
    13511345    }
    13521346
     
    13551349      sh_obscure_index[i] = (unsigned char)0;
    13561350    }
    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;
    13661351
    13671352  while (*endptr != '\0')
     
    13701355      if (i > 255)
    13711356        {
    1372           SL_RETURN(-1, _("sh_util_obscure_ok"));
     1357          SL_RETURN(-1, _("sh_util_obscure_ex"));
    13731358        }
    13741359      sh_obscure_index[i] = (unsigned char)1;
     
    13761361        ++endptr;
    13771362    }
    1378   SL_RETURN(0, _("sh_util_obscure_ok"));
     1363  SL_RETURN(0, _("sh_util_obscure_ex"));
    13791364}
    13801365
    13811366int sh_util_obscurename (ShErrLevel level, char * name_orig, int flag)
    13821367{
    1383   unsigned char * name = (unsigned char *) name_orig;
     1368  char * name = name_orig;
    13841369  char * safe;
    13851370  unsigned int i;
     
    13931378  while (*name != '\0')
    13941379    {
    1395       if ( (*name) >  0x7F || (*name) == '"'  || (*name) == '\t' ||
     1380      if ( (*name) == '"'  || (*name) == '\t' ||
    13961381           (*name) == '\b' || (*name) == '\f' ||
    13971382           (*name) == '\n' || (*name) == '\r' ||
     
    15771562    } else if (!isgraph ((int) *p)) {    /* not printable    */
    15781563      /*@-bufferoverflowhigh -formatconst@*/
    1579       /* flawfinder: ignore */
    15801564      sprintf(oct, format, '\\',                 /* known to fit  */
    15811565              (unsigned char) *p);
Note: See TracChangeset for help on using the changeset viewer.