Changeset 22 for trunk/src/sh_extern.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_extern.c

    r1 r22  
    364364             
    365365              PDBGC(5);
    366               sprintf(pname, _("/proc/self/fd/%d"),      /* known to fit  */
    367                            pfd);
    368               if (access(pname, R_OK|X_OK) == 0)
     366              sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
     367              if (access(pname, R_OK|X_OK) == 0) /* flawfinder: ignore */
    369368                {
    370369                  PDBGC(6);
     
    402401           * --  execute path if executable
    403402           */
    404           if (0 == access(task->command, R_OK|X_OK))
     403          if (0 == access(task->command, R_OK|X_OK)) /* flawfinder: ignore */
    405404            {
    406405              PDBGC(5);
     
    544543              task->exit_status = WEXITSTATUS(task->exit_status);
    545544              if ((flag_err_debug == SL_TRUE) || (task->exit_status != 0))
    546                 sprintf(infomsg,                         /* known to fit  */
    547                         _("Subprocess exited normally with status %d"),
    548                         task->exit_status);
     545                sl_snprintf(infomsg, sizeof(infomsg),
     546                            _("Subprocess exited normally with status %d"),
     547                            task->exit_status);
    549548            }
    550549          else if (WIFSIGNALED(task->exit_status) != 0)
    551550            {
    552               sprintf(infomsg,                           /* known to fit  */
    553                       _("Subprocess terminated by signal %d"),
    554                       WTERMSIG(task->exit_status));
     551              sl_snprintf(infomsg, sizeof(infomsg),
     552                          _("Subprocess terminated by signal %d"),
     553                          WTERMSIG(task->exit_status));
    555554              task->exit_status = EXIT_FAILURE;
    556555            }
    557556          else if (WIFSTOPPED(task->exit_status) != 0)
    558557            {
    559               sprintf(infomsg,                           /* known to fit  */
    560                       _("Subprocess stopped by signal %d, killing"),
    561                       WSTOPSIG(task->exit_status));
     558              sl_snprintf(infomsg, sizeof(infomsg),
     559                          _("Subprocess stopped by signal %d, killing"),
     560                          WSTOPSIG(task->exit_status));
    562561              task->exit_status = EXIT_FAILURE;
    563562              (void) aud_kill (FIL__, __LINE__, task->pid, 9);
     
    567566          else
    568567            {
    569               sprintf(infomsg,                           /* known to fit  */
    570                       _("Subprocess exit status unknown"));
     568              sl_snprintf(infomsg, sizeof(infomsg),
     569                          _("Subprocess exit status unknown"));
    571570              task->exit_status = EXIT_FAILURE;
    572571            }
     
    581580            }
    582581          (void) aud_kill (FIL__, __LINE__, task->pid, 9);
    583           sprintf(infomsg,                               /* known to fit  */
    584                   _("Subprocess not yet exited, killing"));
     582          sl_snprintf(infomsg, sizeof(infomsg),
     583                      _("Subprocess not yet exited, killing"));
    585584          task->exit_status = EXIT_FAILURE;
    586585          (void) waitpid (task->pid, NULL, 0);
     
    588587      else
    589588        {
    590           sprintf(infomsg,                               /* known to fit  */
    591                   _("Waitpid returned error %d\n"), errno);
     589          sl_snprintf(infomsg, sizeof(infomsg),
     590                      _("Waitpid returned error %d\n"), errno);
    592591          task->exit_status = EXIT_FAILURE;
    593592        }
     
    646645
    647646
    648 int sh_ext_tas_add_envv(sh_tas_t * tas, char * key, char * val)
     647int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val)
    649648{
    650649  size_t sk = 0, sv = 0;
     
    697696}
    698697
    699 int sh_ext_tas_add_argv(sh_tas_t * tas, char * val)
     698int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val)
    700699{
    701700  size_t sv = 0;
     
    722721}
    723722
    724 void sh_ext_tas_command(sh_tas_t * tas, char * command)
     723void sh_ext_tas_command(sh_tas_t * tas, const char * command)
    725724{
    726725  size_t len = sl_strlen(command);
     
    842841
    843842static
    844 int sh_ext_add_envv(char * key, char * val)
     843int sh_ext_add_envv(const char * key, const char * val)
    845844{
    846845  SL_ENTER(_("sh_ext_add_envv"));
     
    861860
    862861static
    863 int sh_ext_init(char * command)
     862int sh_ext_init(const char * command)
    864863{
    865864  sh_com_t * retval;
     
    896895
    897896static
    898 int sh_ext_uid (char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
     897int sh_ext_uid (const char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
    899898{
    900899  struct passwd * tempres;
     
    922921
    923922static
    924 int sh_ext_add (char * argstring, int * ntok, char * stok[])
     923int sh_ext_add (const char * argstring, int * ntok, char * stok[])
    925924{
    926925  int    i = 0;
    927926  size_t s;
    928927  char * p;
     928  char * new;
     929  size_t len;
    929930
    930931  SL_ENTER(_("sh_ext_add"));
     
    935936    }
    936937
     938  len = strlen(argstring) + 1;
     939  new = SH_ALLOC(len);
     940  sl_strlcpy(new, argstring, len);
     941
    937942  do
    938943    {
    939944      if (i == 0)
    940         p = strtok (argstring, ", \t");
     945        p = strtok (new, ", \t");
    941946      else
    942947        p = strtok (NULL, ", \t");
     
    957962
    958963  *ntok = i;
     964  SH_FREE(new);
    959965
    960966  SL_RETURN (0, _("sh_ext_add"));
     
    971977 * -- start a new external command, and add it to the list
    972978 */
    973 int sh_ext_setcommand(char * cmd)
     979int sh_ext_setcommand(const char * cmd)
    974980{
    975981  int i;
     
    10181024 * -- add keywords to the OR filter
    10191025 */
    1020 int sh_ext_add_or (char * str)
     1026int sh_ext_add_or (const char * str)
    10211027{
    10221028  if (ext_coms == NULL || ext_failed == (-1))
     
    10281034 * -- add keywords to the AND filter
    10291035 */
    1030 int sh_ext_add_and (char * str)
     1036int sh_ext_add_and (const char * str)
    10311037{
    10321038  if (ext_coms == NULL || ext_failed == (-1))
     
    10381044 * -- add keywords to the NOT filter
    10391045 */
    1040 int sh_ext_add_not (char * str)
     1046int sh_ext_add_not (const char * str)
    10411047{
    10421048  if (ext_coms == NULL || ext_failed == (-1))
     
    10481054 * -- add keywords to the CL argument list
    10491055 */
    1050 int sh_ext_add_argv (char * str)
     1056int sh_ext_add_argv (const char * str)
    10511057{
    10521058  if (ext_coms == NULL || ext_failed == (-1))
     
    10581064 * -- add a path to the environment
    10591065 */
    1060 int sh_ext_add_default (char * dummy)
    1061 {
    1062   /* while this assignment looks ridiculous, it is here to avoid
    1063    * an 'unused parameter' warning
    1064    */
    1065   char * p = (dummy == NULL ? dummy : NULL);
     1066int sh_ext_add_default (const char * dummy)
     1067{
     1068  (void) dummy;
     1069  char * p = NULL;
    10661070  int    i;
    10671071
     
    10841088 * -- add an environment variable
    10851089 */
    1086 int sh_ext_add_environ (char * str)
     1090int sh_ext_add_environ (const char * str)
    10871091{
    10881092  int i;
     
    10951099 * -- set deadtime
    10961100 */
    1097 int sh_ext_deadtime (char * str)
     1101int sh_ext_deadtime (const char * str)
    10981102{
    10991103  long    deadtime = 0;
     
    11191123 * -- define type
    11201124 */
    1121 int sh_ext_type (char * str)
     1125int sh_ext_type (const char * str)
    11221126{
    11231127  SL_ENTER(_("sh_ext_type"));
     
    11541158 * -- define checksum
    11551159 */
    1156 int sh_ext_checksum (char * str)
     1160int sh_ext_checksum (const char * str)
    11571161{
    11581162  SL_ENTER(_("sh_ext_checksum"));
     
    11751179 * -- choose privileges
    11761180 */
    1177 int sh_ext_priv (char * c)
     1181int sh_ext_priv (const char * c)
    11781182{
    11791183
Note: See TracChangeset for help on using the changeset viewer.