Changeset 154 for trunk/src/sh_utmp.c


Ignore:
Timestamp:
Jan 12, 2008, 7:04:06 PM (17 years ago)
Author:
katerina
Message:

Fix more compiler warnings, and a potential NULL dereference in the unix entropy collector.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utmp.c

    r153 r154  
    771771#endif
    772772
     773/* These variables are not used anywhere. They only exist
     774 * to assign &userold, &user to them, which keeps gcc from
     775 * putting them into a register, and avoids the 'clobbered
     776 * by longjmp' warning. And no, 'volatile' proved insufficient.
     777 */
     778void * sh_dummy_userold = NULL;
     779void * sh_dummy_user    = NULL;
     780
     781
    773782static void sh_utmp_addlogin (struct SH_UTMP_S * ut)
    774783{
    775   struct          log_user   * user     = userlist;
    776   volatile struct log_user   * userold  = userlist;
     784  struct log_user   * user     = userlist;
     785  struct log_user   * userold  = userlist;
    777786#ifdef HAVE_UTTYPE 
    778787  struct log_user   * username = userlist;
     
    785794
    786795  SL_ENTER(_("sh_utmp_addlogin"));
     796
     797  /* Take the address to keep gcc from putting them into registers.
     798   * Avoids the 'clobbered by longjmp' warning.
     799   */
     800  sh_dummy_userold = (void*) &userold;
     801  sh_dummy_user    = (void*) &user;
    787802
    788803  if (ut->ut_line[0] == '\0')
     
    804819  while (user != NULL)
    805820    {
    806       if (0 == sl_strncmp(user->ut_tty, ut->ut_line, UT_LINESIZE) )
     821      if (0 == sl_strncmp((char*)(user->ut_tty), ut->ut_line, UT_LINESIZE) )
    807822        break;
    808823      userold = user;
     
    827842          user = SH_ALLOC(sizeof(struct log_user));
    828843          user->next       = userlist;
    829           userlist         = user;
     844          userlist         = (struct log_user *) user;
    830845        }
    831       (void) sl_strlcpy(user->ut_tty,  ut->ut_line, UT_LINESIZE+1);
    832       (void) sl_strlcpy(user->name,    ut->ut_name, UT_NAMESIZE+1);
     846      (void) sl_strlcpy((char*)(user->ut_tty),  ut->ut_line, UT_LINESIZE+1);
     847      (void) sl_strlcpy((char*)(user->name),    ut->ut_name, UT_NAMESIZE+1);
    833848#ifdef HAVE_UTHOST
    834       (void) sl_strlcpy(user->ut_host, ut->ut_host, UT_HOSTSIZE+1);
     849      (void) sl_strlcpy((char*)(user->ut_host), ut->ut_host, UT_HOSTSIZE+1);
    835850#else
    836851      user->ut_host[0] = '\0';
     
    838853#ifdef HAVE_UTADDR
    839854      /*@-type@*//* ut_addr does exist !!! */
    840       (void) sl_strlcpy(user->ut_ship,
     855      (void) sl_strlcpy((char*)(user->ut_ship),
    841856                        my_inet_ntoa(*(struct in_addr*)&(ut->ut_addr)), 16);
    842857      /*@+type@*/
     
    848863          || 0 == sl_strncmp(ut->ut_line, _("ttyq"), 4) /* in virt. console  */
    849864          ) {
    850         status = sh_utmp_login_a(user->name);
     865        status = sh_utmp_login_a((char*)user->name);
    851866        SH_MUTEX_LOCK(mutex_thread_nolog);
    852867        (void) sh_unix_time (user->time, ttt, TIM_MAX);
     
    872887        SH_MUTEX_UNLOCK(mutex_thread_nolog);
    873888      } else
    874         if (0 != sh_utmp_is_virtual(ut->ut_line, user->ut_host))
     889        if (0 != sh_utmp_is_virtual(ut->ut_line, (char*)user->ut_host))
    875890          {       
    876             status = sh_utmp_login_a(user->name);
     891            status = sh_utmp_login_a((char*)user->name);
    877892            SH_MUTEX_LOCK(mutex_thread_nolog);
    878893            (void) sh_unix_time (user->time, ttt, TIM_MAX);
     
    911926      if (user != NULL)
    912927        {
    913           status = sh_utmp_login_r(user->name);
     928          status = sh_utmp_login_r((char*)user->name);
    914929          SH_MUTEX_LOCK(mutex_thread_nolog);
    915930          (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX);
     
    937952          if (user == userlist)
    938953            userlist = user->next;
    939           sh_utmp_logout_morechecks(user);
    940           SH_FREE(user);
     954          sh_utmp_logout_morechecks((struct log_user *)user);
     955          SH_FREE((struct log_user *)user);
    941956          user = NULL;
    942957        }
Note: See TracChangeset for help on using the changeset viewer.