You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

  1. From 942b77d84417298fb9e99c216029f22fbd1e2d98 Mon Sep 17 00:00:00 2001
  2. From: Michael Heimpold <mhei@heimpold.de>
  3. Date: Thu, 14 Jul 2016 01:47:05 +0200
  4. Subject: [PATCH 13/16] Fix tests for legacy interface
  5. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  6. ---
  7. dio.c | 16 ++++++++++------
  8. 1 file changed, 10 insertions(+), 6 deletions(-)
  9. diff --git a/dio.c b/dio.c
  10. index 7bad575..1a130a2 100644
  11. --- a/dio.c
  12. +++ b/dio.c
  13. @@ -73,9 +73,9 @@ static int new_php_fd(php_fd_t **f, int fd)
  14. return 1;
  15. }
  16. -static void _dio_close_fd(zend_resource *res)
  17. +static void _dio_close_fd(zend_resource *rsrc)
  18. {
  19. - php_fd_t *f = (php_fd_t *)zend_fetch_resource(res, NULL, le_fd);
  20. + php_fd_t *f = (php_fd_t *)rsrc->ptr;
  21. if (f) {
  22. close(f->fd);
  23. free(f);
  24. @@ -87,8 +87,8 @@ static void _dio_close_fd(zend_resource *res)
  25. PHP_FUNCTION(dio_open)
  26. {
  27. php_fd_t *f;
  28. - char *file_name;
  29. - int file_name_length;
  30. + char *file_name = NULL;
  31. + size_t file_name_length = 0;
  32. long flags;
  33. long mode = 0;
  34. int fd;
  35. @@ -97,6 +97,10 @@ PHP_FUNCTION(dio_open)
  36. return;
  37. }
  38. + if (!file_name || file_name[0] == '\0') {
  39. + RETURN_FALSE;
  40. + }
  41. +
  42. if (php_check_open_basedir(file_name) || DIO_SAFE_MODE_CHECK(file_name, "wb+")) {
  43. RETURN_FALSE;
  44. }
  45. @@ -176,7 +180,7 @@ PHP_FUNCTION(dio_dup)
  46. RETURN_FALSE;
  47. }
  48. - RETVAL_RES(zend_register_resource(f, le_fd));
  49. + RETVAL_RES(zend_register_resource(df, le_fd));
  50. }
  51. /* }}} */
  52. #endif
  53. @@ -660,7 +664,7 @@ PHP_FUNCTION(dio_close)
  54. RETURN_FALSE;
  55. }
  56. - zend_list_delete(Z_LVAL_P(r_fd));
  57. + zend_list_delete(Z_RES_P(r_fd));
  58. }
  59. /* }}} */
  60. --
  61. 2.5.0