Changeset 40 for trunk/src/sh_socket.c
- Timestamp:
- May 31, 2006, 9:38:30 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_socket.c
r34 r40 111 111 int pf_unix_fd = -1; 112 112 static char * sh_sockname = NULL; 113 /* static char sh_sockpass[29]; */ 114 static char sh_sockpass_real[15]; 113 static char sh_sockpass_real[SOCKPASS_MAX+1]; 115 114 116 115 struct socket_cmd { … … 226 225 { 227 226 int j = 0; 228 while (skey->sh_sockpass[2*j] != '\0' )227 while (skey->sh_sockpass[2*j] != '\0' && j < sizeof(sh_sockpass_real)) 229 228 { 230 229 sh_sockpass_real[j] = skey->sh_sockpass[2*j]; … … 309 308 310 309 i = sl_strlen(c); 311 if (i > 14) {310 if (i > SOCKPASS_MAX) { 312 311 return -1; 313 312 } 314 for (j = 0; j < 29; ++j)313 for (j = 0; j < (2*SOCKPASS_MAX+1); ++j) 315 314 { 316 315 skey->sh_sockpass[j] = '\0'; … … 556 555 557 556 iov.iov_base = (char *) &message; 558 iov.iov_len = SH_MAXMSG;557 iov.iov_len = sizeof(message); 559 558 560 559 memset (&msg, 0, sizeof (msg)); … … 626 625 #endif 627 626 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'; 631 630 632 631 if (nbytes < 0) … … 684 683 if (eopw) 685 684 *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)) 687 690 { 688 691 client_uid = sh_socket_flaguid; … … 808 811 while (list_cmd) 809 812 { 810 sl_snprintf(message, SH_MAXMSG, _("SENT %8s %32s %s"),813 sl_snprintf(message, sizeof(message), _("SENT %8s %32s %s"), 811 814 list_cmd->cmd, list_cmd->clt, list_cmd->cti); 812 815 /* … … 835 838 while (list_cmd) 836 839 { 837 sl_snprintf(message, SH_MAXMSG, _(">>>> %8s %32s %s"),840 sl_snprintf(message, sizeof(message), _(">>>> %8s %32s %s"), 838 841 list_cmd->cmd, list_cmd->clt, list_cmd->cti); 839 842 /* … … 964 967 } 965 968 966 sl_strlcpy(cancel_cmd, _("CANCEL"), SH_MAXMSGLEN);969 sl_strlcpy(cancel_cmd, _("CANCEL"), sizeof(cancel_cmd)); 967 970 968 971 while (sh_socket_read (&cmd) > 0) … … 994 997 if (0 == sl_strcmp(new->clt, client_name)) 995 998 { 996 sl_strlcpy(out, new->cmd, SH_MAXMSGLEN);999 sl_strlcpy(out, new->cmd, sizeof(out)); 997 1000 sh_socket_add2run (new); 998 1001 sh_socket_rm2list (client_name);
Note:
See TracChangeset
for help on using the changeset viewer.