cvs: php4 /ext/sockets sockets.c

From: Date: Mon, 11 Sep 2000 16:19:53 +0000
Subject: cvs: php4 /ext/sockets sockets.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1709@lists.php.net to get a copy of this message
sas Mon Sep 11 09:19:53 2000 EDT Modified files: /php4/ext/sockets sockets.c Log: Add proper struct sockaddr * casts and make use of memcpy/memset ('coz we don't provide any fallbacks for bcopy/bzero). Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.10 php4/ext/sockets/sockets.c:1.11 --- php4/ext/sockets/sockets.c:1.10 Sun Sep 10 16:18:11 2000 +++ php4/ext/sockets/sockets.c Mon Sep 11 09:19:53 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sockets.c,v 1.10 2000/09/10 23:18:11 sterling Exp $ */ +/* $Id: sockets.c,v 1.11 2000/09/11 16:19:53 sas Exp $ */ #include "php.h" @@ -430,7 +430,7 @@ return -1; } - bcopy(hp->h_addr, (char *)&la.sin_addr, hp->h_length); + memcpy((char *)&la.sin_addr, hp->h_addr, hp->h_length); la.sin_family = hp->h_addrtype; la.sin_port = htons(port); @@ -633,7 +633,7 @@ v_convert_to_long_ex(2, fd, port); convert_to_string_ex(addr); - ret = getsockname(Z_LVAL_PP(fd), &sa, &salen); + ret = getsockname(Z_LVAL_PP(fd), (struct sockaddr *) &sa, &salen); if (ret < 0) { RETURN_LONG(-errno); } else { @@ -643,7 +643,7 @@ inet_ntoa_lock = 1; addr_string = inet_ntoa(sa.sin_addr); tmp = emalloc(strlen(addr_string) + 1); - bzero(tmp, strlen(addr_string) + 1); + memset(tmp, 0, strlen(addr_string) + 1); strncpy(tmp, addr_string, strlen(addr_string)); inet_ntoa_lock = 0; @@ -729,7 +729,7 @@ v_convert_to_long_ex(2, fd, port); convert_to_string_ex(addr); - ret = getpeername(Z_LVAL_PP(fd), &sa, &salen); + ret = getpeername(Z_LVAL_PP(fd), (struct sockaddr *) &sa, &salen); if (ret < 0) { RETURN_LONG(-errno); @@ -740,7 +740,7 @@ inet_ntoa_lock = 1; addr_string = inet_ntoa(sa.sin_addr); tmp = emalloc(strlen(addr_string) + 1); - bzero(tmp, strlen(addr_string) + 1); + memset(tmp, 0, strlen(addr_string) + 1); strncpy(tmp, addr_string, strlen(addr_string)); inet_ntoa_lock = 0; @@ -863,7 +863,7 @@ convert_to_long_ex(port); } - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); ret = getsockname(Z_LVAL_PP(sockfd), &sa, &salen); if (ret < 0) { @@ -968,7 +968,7 @@ if (sock_type.sa_family == AF_UNIX) { struct sockaddr_un sa; snprintf(sa.sun_path, 108, "%s", Z_STRVAL_PP(arg1)); - ret = bind(Z_LVAL_PP(arg0), &sa, SUN_LEN(&sa)); + ret = bind(Z_LVAL_PP(arg0), (struct sockaddr *) &sa, SUN_LEN(&sa)); } else if (sock_type.sa_family == AF_INET) { struct sockaddr_in sa; struct in_addr addr_buf; @@ -991,7 +991,7 @@ sa.sin_addr.s_addr = addr_buf.s_addr; } - ret = bind(Z_LVAL_PP(arg0), &sa, sizeof(sa)); + ret = bind(Z_LVAL_PP(arg0), (struct sockaddr *) &sa, sizeof(sa)); } else { RETURN_LONG(-EPROTONOSUPPORT); } @@ -1115,7 +1115,7 @@ ZEND_FETCH_RESOURCE(vector, php_iovec_t *, iovec_id, -1, "IO vector table", SOCKETSG(le_iov)); vector_array = emalloc(sizeof(struct iovec) * (vector->count + 2)); - bcopy(vector->iov_array, vector_array, sizeof(struct iovec) * vector->count); + memcpy(vector_array, vector->iov_array, sizeof(struct iovec) * vector->count); vector_array[vector->count].iov_base = emalloc(Z_LVAL_PP(iov_len)); vector_array[vector->count].iov_len = Z_LVAL_PP(iov_len); @@ -1153,9 +1153,9 @@ for (i = 0; i < vector->count; i++) { if (i < Z_LVAL_PP(iov_pos)) { - bcopy(&(vector_array[i]), &(vector->iov_array[i]), sizeof(struct iovec)); + memcpy(&(vector->iov_array[i]), &(vector_array[i]), sizeof(struct iovec)); } else if (i > Z_LVAL_PP(iov_pos)) { - bcopy(&(vector_array[i - 1]), &(vector->iov_array[i]), sizeof(struct iovec)); + memcpy(&(vector->iov_array[i]), &(vector_array[i - 1]), sizeof(struct iovec)); } } @@ -1249,7 +1249,7 @@ convert_to_string_ex(buf); recv_buf = emalloc(Z_LVAL_PP(len) + 2); - bzero(recv_buf, Z_LVAL_PP(len) + 2); + memset(recv_buf, 0, Z_LVAL_PP(len) + 2); ret = recv(Z_LVAL_PP(fd), recv_buf, Z_LVAL_PP(len), Z_LVAL_PP(flags)); @@ -1337,7 +1337,7 @@ if (ZEND_NUM_ARGS() != 5) { WRONG_PARAM_COUNT; } - bzero(recv_buf, Z_LVAL_PP(len) + 2); + memset(recv_buf, 0, Z_LVAL_PP(len) + 2); ret = recvfrom(Z_LVAL_PP(fd), recv_buf, Z_LVAL_PP(len), Z_LVAL_PP(flags), (struct sockaddr *)&sun, (socklen_t *) & sun_length); @@ -1376,7 +1376,7 @@ if (ZEND_NUM_ARGS() != 6) { WRONG_PARAM_COUNT; } - bzero(recv_buf, Z_LVAL_PP(len) + 2); + memset(recv_buf, 0, Z_LVAL_PP(len) + 2); ret = recvfrom(Z_LVAL_PP(fd), recv_buf, Z_LVAL_PP(len), Z_LVAL_PP(flags), (struct sockaddr *)&sin, (socklen_t *) & sin_length); @@ -1463,12 +1463,12 @@ if (ZEND_NUM_ARGS() != 5) { WRONG_PARAM_COUNT; } - bzero(&sun, sizeof(sun)); + memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; snprintf(sun.sun_path, 108, "%s", Z_STRVAL_PP(port)); ret = sendto(Z_LVAL_PP(fd), Z_STRVAL_PP(buf), (Z_STRLEN_PP(buf) > Z_LVAL_PP(len) ? Z_LVAL_PP(len) : Z_STRLEN_PP(buf)), - Z_LVAL_PP(flags), &sun, SUN_LEN(&sun)); + Z_LVAL_PP(flags), (struct sockaddr *) &sun, SUN_LEN(&sun)); RETURN_LONG(((ret < 0) ? -errno : ret)); } @@ -1481,7 +1481,7 @@ if (ZEND_NUM_ARGS() != 6) { WRONG_PARAM_COUNT; } - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; if (inet_aton(Z_STRVAL_PP(addr), &addr_buf) == 0) { @@ -1498,7 +1498,7 @@ sin.sin_port = htons(Z_LVAL_PP(port)); ret = sendto(Z_LVAL_PP(fd), Z_STRVAL_PP(buf), (Z_STRLEN_PP(buf) > Z_LVAL_PP(len) ? Z_LVAL_PP(len) : Z_STRLEN_PP(buf)), - Z_LVAL_PP(flags), &sin, sizeof(sin)); + Z_LVAL_PP(flags), (struct sockaddr *) &sin, sizeof(sin)); RETURN_LONG(((ret < 0) ? -errno : ret)); } @@ -1570,7 +1570,7 @@ efree(ctl_buf); WRONG_PARAM_COUNT; } - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); hdr.msg_name = sin; hdr.msg_namelen = sizeof(sa); hdr.msg_iov = iov->iov_array; @@ -1629,7 +1629,7 @@ efree(ctl_buf); WRONG_PARAM_COUNT; } - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); hdr.msg_name = sun; hdr.msg_namelen = sizeof(sa); hdr.msg_iov = iov->iov_array; @@ -1708,7 +1708,7 @@ struct sockaddr_in *sin = (struct sockaddr_in *) &sa; h_errno = 0; errno = 0; - bzero(&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.msg_name = &sa; hdr.msg_namelen = sizeof(sa); hdr.msg_iov = iov->iov_array;

« previous php.cvs (#1709) next »