Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_extern.c

    r1 r29  
    115115  FILE * outf = NULL;
    116116  char * envp[1];
    117   char * argp[1];
     117  char * argp[2];
    118118
    119119  char * errfile;
     
    133133   *         needs a valid *envp[] with envp[0] = NULL;
    134134   *         and similarly for argp
     135   * OpenBSD finally needs non-null argp[0] ...
    135136   */
     137  argp[0] = task->command;
     138  argp[1] = NULL;
    136139  envp[0] = NULL;
    137   argp[0] = NULL;
    138140
    139141  /*
     
    364366             
    365367              PDBGC(5);
    366               sprintf(pname, _("/proc/self/fd/%d"),      /* known to fit  */
    367                            pfd);
    368               if (access(pname, R_OK|X_OK) == 0)
     368              sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
     369              if (access(pname, R_OK|X_OK) == 0) /* flawfinder: ignore */
    369370                {
    370371                  PDBGC(6);
     
    402403           * --  execute path if executable
    403404           */
    404           if (0 == access(task->command, R_OK|X_OK))
     405          if (0 == access(task->command, R_OK|X_OK)) /* flawfinder: ignore */
    405406            {
    406407              PDBGC(5);
     
    544545              task->exit_status = WEXITSTATUS(task->exit_status);
    545546              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);
     547                sl_snprintf(infomsg, sizeof(infomsg),
     548                            _("Subprocess exited normally with status %d"),
     549                            task->exit_status);
    549550            }
    550551          else if (WIFSIGNALED(task->exit_status) != 0)
    551552            {
    552               sprintf(infomsg,                           /* known to fit  */
    553                       _("Subprocess terminated by signal %d"),
    554                       WTERMSIG(task->exit_status));
     553              sl_snprintf(infomsg, sizeof(infomsg),
     554                          _("Subprocess terminated by signal %d"),
     555                          WTERMSIG(task->exit_status));
    555556              task->exit_status = EXIT_FAILURE;
    556557            }
    557558          else if (WIFSTOPPED(task->exit_status) != 0)
    558559            {
    559               sprintf(infomsg,                           /* known to fit  */
    560                       _("Subprocess stopped by signal %d, killing"),
    561                       WSTOPSIG(task->exit_status));
     560              sl_snprintf(infomsg, sizeof(infomsg),
     561                          _("Subprocess stopped by signal %d, killing"),
     562                          WSTOPSIG(task->exit_status));
    562563              task->exit_status = EXIT_FAILURE;
    563564              (void) aud_kill (FIL__, __LINE__, task->pid, 9);
     
    567568          else
    568569            {
    569               sprintf(infomsg,                           /* known to fit  */
    570                       _("Subprocess exit status unknown"));
     570              sl_snprintf(infomsg, sizeof(infomsg),
     571                          _("Subprocess exit status unknown"));
    571572              task->exit_status = EXIT_FAILURE;
    572573            }
     
    581582            }
    582583          (void) aud_kill (FIL__, __LINE__, task->pid, 9);
    583           sprintf(infomsg,                               /* known to fit  */
    584                   _("Subprocess not yet exited, killing"));
     584          sl_snprintf(infomsg, sizeof(infomsg),
     585                      _("Subprocess not yet exited, killing"));
    585586          task->exit_status = EXIT_FAILURE;
    586587          (void) waitpid (task->pid, NULL, 0);
     
    588589      else
    589590        {
    590           sprintf(infomsg,                               /* known to fit  */
    591                   _("Waitpid returned error %d\n"), errno);
     591          sl_snprintf(infomsg, sizeof(infomsg),
     592                      _("Waitpid returned error %d\n"), errno);
    592593          task->exit_status = EXIT_FAILURE;
    593594        }
     
    646647
    647648
    648 int sh_ext_tas_add_envv(sh_tas_t * tas, char * key, char * val)
     649int sh_ext_tas_add_envv(sh_tas_t * tas, const char * key, const char * val)
    649650{
    650651  size_t sk = 0, sv = 0;
     
    697698}
    698699
    699 int sh_ext_tas_add_argv(sh_tas_t * tas, char * val)
     700int sh_ext_tas_add_argv(sh_tas_t * tas, const char * val)
    700701{
    701702  size_t sv = 0;
     
    722723}
    723724
    724 void sh_ext_tas_command(sh_tas_t * tas, char * command)
     725void sh_ext_tas_command(sh_tas_t * tas, const char * command)
    725726{
    726727  size_t len = sl_strlen(command);
     
    842843
    843844static
    844 int sh_ext_add_envv(char * key, char * val)
     845int sh_ext_add_envv(const char * key, const char * val)
    845846{
    846847  SL_ENTER(_("sh_ext_add_envv"));
     
    861862
    862863static
    863 int sh_ext_init(char * command)
     864int sh_ext_init(const char * command)
    864865{
    865866  sh_com_t * retval;
     
    896897
    897898static
    898 int sh_ext_uid (char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
     899int sh_ext_uid (const char * user, /*@out@*/uid_t * uid, /*@out@*/gid_t * gid)
    899900{
    900901  struct passwd * tempres;
     
    922923
    923924static
    924 int sh_ext_add (char * argstring, int * ntok, char * stok[])
     925int sh_ext_add (const char * argstring, int * ntok, char * stok[])
    925926{
    926927  int    i = 0;
    927928  size_t s;
    928929  char * p;
     930  char * new;
     931  size_t len;
    929932
    930933  SL_ENTER(_("sh_ext_add"));
     
    935938    }
    936939
     940  len = strlen(argstring) + 1;
     941  new = SH_ALLOC(len);
     942  sl_strlcpy(new, argstring, len);
     943
    937944  do
    938945    {
    939946      if (i == 0)
    940         p = strtok (argstring, ", \t");
     947        p = strtok (new, ", \t");
    941948      else
    942949        p = strtok (NULL, ", \t");
     
    957964
    958965  *ntok = i;
     966  SH_FREE(new);
    959967
    960968  SL_RETURN (0, _("sh_ext_add"));
     
    971979 * -- start a new external command, and add it to the list
    972980 */
    973 int sh_ext_setcommand(char * cmd)
     981int sh_ext_setcommand(const char * cmd)
    974982{
    975983  int i;
     
    10181026 * -- add keywords to the OR filter
    10191027 */
    1020 int sh_ext_add_or (char * str)
     1028int sh_ext_add_or (const char * str)
    10211029{
    10221030  if (ext_coms == NULL || ext_failed == (-1))
     
    10281036 * -- add keywords to the AND filter
    10291037 */
    1030 int sh_ext_add_and (char * str)
     1038int sh_ext_add_and (const char * str)
    10311039{
    10321040  if (ext_coms == NULL || ext_failed == (-1))
     
    10381046 * -- add keywords to the NOT filter
    10391047 */
    1040 int sh_ext_add_not (char * str)
     1048int sh_ext_add_not (const char * str)
    10411049{
    10421050  if (ext_coms == NULL || ext_failed == (-1))
     
    10481056 * -- add keywords to the CL argument list
    10491057 */
    1050 int sh_ext_add_argv (char * str)
     1058int sh_ext_add_argv (const char * str)
    10511059{
    10521060  if (ext_coms == NULL || ext_failed == (-1))
     
    10581066 * -- add a path to the environment
    10591067 */
    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);
     1068int sh_ext_add_default (const char * dummy)
     1069{
     1070  (void) dummy;
     1071  char * p = NULL;
    10661072  int    i;
    10671073
     
    10841090 * -- add an environment variable
    10851091 */
    1086 int sh_ext_add_environ (char * str)
     1092int sh_ext_add_environ (const char * str)
    10871093{
    10881094  int i;
     
    10951101 * -- set deadtime
    10961102 */
    1097 int sh_ext_deadtime (char * str)
     1103int sh_ext_deadtime (const char * str)
    10981104{
    10991105  long    deadtime = 0;
     
    11191125 * -- define type
    11201126 */
    1121 int sh_ext_type (char * str)
     1127int sh_ext_type (const char * str)
    11221128{
    11231129  SL_ENTER(_("sh_ext_type"));
     
    11541160 * -- define checksum
    11551161 */
    1156 int sh_ext_checksum (char * str)
     1162int sh_ext_checksum (const char * str)
    11571163{
    11581164  SL_ENTER(_("sh_ext_checksum"));
     
    11751181 * -- choose privileges
    11761182 */
    1177 int sh_ext_priv (char * c)
     1183int sh_ext_priv (const char * c)
    11781184{
    11791185
Note: See TracChangeset for help on using the changeset viewer.