Changeset 40 for trunk/src/sh_socket.c


Ignore:
Timestamp:
May 31, 2006, 9:38:30 PM (18 years ago)
Author:
rainer
Message:

Fix for tickets #13, #14, #15, #16, #17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_socket.c

    r34 r40  
    111111int    pf_unix_fd  = -1;
    112112static char * sh_sockname = NULL;
    113 /* static char   sh_sockpass[29]; */
    114 static char   sh_sockpass_real[15];
     113static char   sh_sockpass_real[SOCKPASS_MAX+1];
    115114
    116115struct socket_cmd {
     
    226225{
    227226  int j = 0;
    228   while (skey->sh_sockpass[2*j] != '\0')
     227  while (skey->sh_sockpass[2*j] != '\0' && j < sizeof(sh_sockpass_real))
    229228    {
    230229      sh_sockpass_real[j] = skey->sh_sockpass[2*j];
     
    309308
    310309  i = sl_strlen(c);
    311   if (i > 14) {
     310  if (i > SOCKPASS_MAX) {
    312311    return -1;
    313312  }
    314   for (j = 0; j < 29; ++j)
     313  for (j = 0; j < (2*SOCKPASS_MAX+1); ++j)
    315314    {
    316315      skey->sh_sockpass[j] = '\0';
     
    556555
    557556  iov.iov_base = (char *) &message;
    558   iov.iov_len  = SH_MAXMSG;
     557  iov.iov_len  = sizeof(message);
    559558
    560559  memset (&msg, 0, sizeof (msg));
     
    626625#endif
    627626
    628   /* nbytes = recv (talkfd, message, SH_MAXMSG, 0); */
    629 
    630   message[SH_MAXMSG-1] = '\0';
     627  /* msg.msg_iov.iov_base, filled by recvmsg
     628   */
     629  message[sizeof(message)-1] = '\0';
    631630
    632631  if (nbytes < 0)
     
    684683  if (eopw)
    685684    *eopw = '\0';
    686   if (0 == strcmp(goodpassword, message))
     685  /*
     686   * message is null-terminated and >> goodpassword
     687   */
     688  if (0 == strcmp(goodpassword, message) &&
     689      strlen(goodpassword) < (sizeof(message)/2))
    687690    {
    688691      client_uid = sh_socket_flaguid;
     
    808811      while (list_cmd)
    809812        {
    810           sl_snprintf(message, SH_MAXMSG, _("SENT  %8s  %32s  %s"),
     813          sl_snprintf(message, sizeof(message), _("SENT  %8s  %32s  %s"),
    811814                      list_cmd->cmd, list_cmd->clt, list_cmd->cti);
    812815          /*
     
    835838  while (list_cmd)
    836839    {
    837       sl_snprintf(message, SH_MAXMSG, _(">>>>  %8s  %32s  %s"),
     840      sl_snprintf(message, sizeof(message), _(">>>>  %8s  %32s  %s"),
    838841                  list_cmd->cmd, list_cmd->clt, list_cmd->cti);
    839842      /*
     
    964967    }
    965968
    966   sl_strlcpy(cancel_cmd, _("CANCEL"), SH_MAXMSGLEN);
     969  sl_strlcpy(cancel_cmd, _("CANCEL"), sizeof(cancel_cmd));
    967970
    968971  while (sh_socket_read (&cmd) > 0)
     
    994997      if (0 == sl_strcmp(new->clt, client_name))
    995998        {
    996           sl_strlcpy(out, new->cmd, SH_MAXMSGLEN);
     999          sl_strlcpy(out, new->cmd, sizeof(out));
    9971000          sh_socket_add2run (new);
    9981001          sh_socket_rm2list  (client_name);
Note: See TracChangeset for help on using the changeset viewer.