Changeset 153 for trunk/src


Ignore:
Timestamp:
Jan 11, 2008, 11:47:17 PM (17 years ago)
Author:
katerina
Message:

Use -D_FORTIFY_SOURCE=1 -fstack-protector-all if supported. Compiler warnings fixed.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain.c

    r149 r153  
    13911391          my_argv[0] = argv[0]; ++my_argc; 
    13921392          command_line[0] = '\0';
    1393           (void*) fgets (command_line, sizeof(command_line), stdin);
    1394           command_line[sizeof(command_line)-1] = '\0';
     1393          if (NULL != fgets (command_line, sizeof(command_line), stdin))
     1394            command_line[sizeof(command_line)-1] = '\0';
     1395
    13951396          do {
    13961397#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     
    19611962              (void) sh_dirs_chk  (1);
    19621963#ifndef SH_PROFILE
    1963               (void) chdir ("/");
     1964              (void) retry_aud_chdir (FIL__, __LINE__, "/");
    19641965#endif
    19651966            }
     
    19681969              (void) sh_dirs_chk  (2);
    19691970#ifndef SH_PROFILE
    1970               (void) chdir ("/");
     1971              (void) retry_aud_chdir (FIL__, __LINE__, "/");
    19711972#endif
    19721973            }
  • trunk/src/sh_entropy.c

    r147 r153  
    618618      }
    619619     
    620       freopen (_("/dev/null"), "r+", stderr);
     620      if (NULL != freopen (_("/dev/null"), "r+", stderr))
     621        {
    621622     
    622       /* exec the program */
    623       retry_aud_execve (FIL__, __LINE__, _("/bin/sh"), arg, envp);
    624      
     623          /* exec the program */
     624          retry_aud_execve (FIL__, __LINE__, _("/bin/sh"), arg, envp);
     625        }
     626
    625627      /* failed
    626628       */
  • trunk/src/sh_err_console.c

    r137 r153  
    286286  struct sigaction sa_new, sa_old;
    287287  static int blockMe = 0;
     288  int    val_return;
    288289
    289290  SL_ENTER(_("sh_log_console"));
     
    315316    {
    316317      len = strlen(errmsg);
    317       (void) write(STDERR_FILENO, errmsg, len);
    318       (void) write(STDERR_FILENO, "\n", 1);
     318      do {
     319        val_return = write(STDERR_FILENO, errmsg, len);
     320      } while (val_return < 0 && errno == EINTR);
     321      do {
     322        val_return = write(STDERR_FILENO, "\n", 1);
     323      } while (val_return < 0 && errno == EINTR);
    319324      /*
    320325       * fprintf (stderr, "%s\n", errmsg);
     
    367372          if (fd[cc] >= 0)
    368373            {
    369               (void) write(fd[cc], errmsg, strlen(errmsg));
    370               (void) write(fd[cc], "\r\n",              2);
     374              do {
     375                val_return = write(fd[cc], errmsg, strlen(errmsg));
     376              } while (val_return < 0 && errno == EINTR);
     377              do {
     378                val_return = write(fd[cc], "\r\n",              2);
     379              } while (val_return < 0 && errno == EINTR);
    371380              (void) close(fd[cc]);
    372381              service_failure[cc] = 0;
  • trunk/src/sh_err_log.c

    r138 r153  
    392392                  (void) fflush(stdout);
    393393                  key[0] = '\0';
    394                   (void) fgets(key, sizeof(key), stdin);
    395                   if (key[0] != '\n')
     394                  if (NULL != fgets(key, sizeof(key), stdin))
    396395                    {
    397                       if (key[strlen(key) - 1] == '\n')
    398                         key[strlen(key) - 1] = '\0';
    399                     }
    400                   if (key[0] == '/')
    401                     {
    402                       chk_mode = CHK_FIL;
    403                       (void) sl_strlcpy(path, key, KEY_LEN+1);
    404                       break;
     396                      if (key[0] != '\n')
     397                        {
     398                          if (key[strlen(key) - 1] == '\n')
     399                            key[strlen(key) - 1] = '\0';
     400                        }
     401                      if (key[0] == '/')
     402                        {
     403                          chk_mode = CHK_FIL;
     404                          (void) sl_strlcpy(path, key, KEY_LEN+1);
     405                          break;
     406                        }
    405407                    }
    406408                }
  • trunk/src/sh_gpg.c

    r137 r153  
    489489      sh_unix_closeall (3, -1); /* in child process */
    490490
    491       freopen(_("/dev/null"), "r+", stderr);
     491      if (NULL == freopen(_("/dev/null"), "r+", stderr))
     492        {
     493          dlog(1, FIL__, __LINE__, _("Internal error: freopen failed\n"));
     494          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
     495        }
    492496
    493497      /* We should become privileged if SUID,
  • trunk/src/sh_hash.c

    r149 r153  
    459459
    460460 unlock_and_return:
     461  ; /* 'label at end of compound statement */
    461462  SH_MUTEX_UNLOCK(mutex_hash);
    462463  return retval;
     
    13491350
    13501351 unlock_and_return:
     1352  ; /* 'label at end of compound statement */
    13511353  SH_MUTEX_UNLOCK(mutex_hash);
    13521354  SL_RET0(_("sh_hash_init"));
     
    13771379
    13781380 unlock_and_exit:
     1381  ; /* 'label at end of compound statement */
    13791382  SH_MUTEX_UNLOCK(mutex_hash);
    13801383  SL_RET0(_("sh_hash_hashdelete"));
     
    17921795        sl_write_line_fast (pushdata_fd, attr_string, sl_strlen(attr_string));
    17931796    } else {
    1794       fwrite (&p, sizeof(sh_filestore_t), 1, stdout);
    1795       printf ("%s\n", fullpath);
    1796       printf ("%s\n", linkpath);
    1797       if (attr_string)
    1798         printf ("%s\n", attr_string);
     1797      if (fwrite (&p, sizeof(sh_filestore_t), 1, stdout))
     1798        {
     1799          printf ("%s\n", fullpath);
     1800          printf ("%s\n", linkpath);
     1801          if (attr_string)
     1802            printf ("%s\n", attr_string);
     1803        }
     1804      else
     1805        {
     1806          perror(_("Error writing database"));
     1807          aud_exit (FIL__, __LINE__, EXIT_FAILURE);
     1808        }
    17991809    }
    18001810
     
    27282738
    27292739  char log_policy[32];
    2730   int  log_severity;
     2740  volatile int  log_severity;
    27312741  char hashbuf[KEYBUF_SIZE];
    27322742
     
    35043514
    35053515 unlock_and_return:
    3506 
     3516  ; /* 'label at end of compound statement */
    35073517  SH_MUTEX_UNLOCK(mutex_hash);
    35083518  SL_RETURN(retval, _("sh_hash_compdata"));
  • trunk/src/sh_mem.c

    r149 r153  
    260260void sh_mem_free (void * a, char * file, int line)
    261261{
    262   memlist_t * this   = memlist;
    263   memlist_t * before = memlist;
    264   unsigned long size = 0;
     262  volatile memlist_t * this   = memlist;
     263  memlist_t          * before = memlist;
     264  unsigned long        size  = 0;
    265265
    266266  SL_ENTER(_("sh_mem_free"));
  • trunk/src/sh_unix.c

    r151 r153  
    411411#define STDERR_FILENO 2
    412412#endif
    413     write(STDERR_FILENO,  msg, strlen(msg));
    414     write(STDERR_FILENO, "\n", 1);
     413    int retval = 0;
     414    do {
     415      retval = write(STDERR_FILENO,  msg, strlen(msg));
     416    } while (retval < 0 && errno == EINTR);
     417    do {
     418      retval = write(STDERR_FILENO, "\n", 1);
     419    } while (retval < 0 && errno == EINTR);
    415420    return 0;
    416421  }
     
    468473  }
    469474  sl_strlcat(msg, details, 128);
    470   safe_logger (signal, method, msg);
     475  (void) safe_logger (signal, method, msg);
    471476  _exit(EXIT_FAILURE);
    472477}
     
    507512      if (immediate_exit_normal == 2)
    508513        {
    509           chdir ("/");
     514          int val_return;
     515
     516          do {
     517            val_return = chdir ("/");
     518          } while (val_return < 0 && errno == EINTR);
     519
    510520          safe_logger (mysignal, 0, NULL);
    511521        }
     
    30323042    {
    30333043      char hashbuf[KEYBUF_SIZE];
     3044      UINT64 local_length = (UINT64) (tmpFile.size < 0 ? 0 : tmpFile.size);
    30343045      sl_strlcpy(fileHash,
    3035                  sh_tiger_generic_hash (filename, fd, &(tmpFile.size),
     3046                 sh_tiger_generic_hash (filename, fd, &(local_length),
    30363047                                        alert_timeout, hashbuf, sizeof(hashbuf)),
    30373048                 KEY_LEN+1);
  • trunk/src/sh_utmp.c

    r149 r153  
    773773static void sh_utmp_addlogin (struct SH_UTMP_S * ut)
    774774{
    775   struct log_user   * user     = userlist;
    776   struct log_user   * userold  = userlist;
     775  struct          log_user   * user     = userlist;
     776  volatile struct log_user   * userold  = userlist;
    777777#ifdef HAVE_UTTYPE 
    778778  struct log_user   * username = userlist;
     
    781781  char   ttt[TIM_MAX];
    782782#ifdef HAVE_UTTYPE
    783   int    status;
     783  volatile int    status;
    784784#endif
    785785
Note: See TracChangeset for help on using the changeset viewer.