com php-src: Check return of fstat(): ext/sockets/sendrecvmsg.c
| From: | Gustavo André dos Santos Lopes | Date: | Sat, 02 Feb 2013 15:38:07 +0000 |
| Subject: | com php-src: Check return of fstat(): ext/sockets/sendrecvmsg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71131@lists.php.net to get a copy of this message | ||
Commit: 5bf7b08efd691780f421e0b4f176404fe3a80b2c
Author: Gustavo Lopes <glopes@nebm.ist.utl.pt> Mon, 5 Nov 2012 17:35:46 +0100
Parents: 190a0ed71377519425f1b33ef3b21f41064e416b
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5bf7b08efd691780f421e0b4f176404fe3a80b2c
Log:
Check return of fstat()
Changed paths:
M ext/sockets/sendrecvmsg.c
Diff:
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index 4436d18..16330e0 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -1387,7 +1387,12 @@ static void to_zval_read_fd_array(const char *data, zval *zv, res_context
*ctx)
fd = *((int *)data + i);
/* determine whether we have a socket */
- fstat(fd, &statbuf);
+ if (fstat(fd, &statbuf) == -1) {
+ do_to_zval_err(ctx, "error creating resource for received file "
+ "descriptor %d: fstat() call failed with errno %d", fd, errno);
+ efree(elem);
+ return;
+ }
if (S_ISSOCK(statbuf.st_mode)) {
php_socket *sock = socket_import_file_descriptor(fd);
zend_register_resource(elem, sock, php_sockets_le_socket());