Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Miscellany
Monday, November 27th, 2006 at 4:59:44pm UTC 

  1. --- filestat.old        2006-11-27 15:44:12.154290752 +0000
  2. +++ filestat.c  2006-11-27 22:52:36.569625656 +0000
  3. @@ -356,21 +356,29 @@
  4.  {
  5.         zval **filename, **group;
  6.         gid_t gid;
  7. -       struct group *gr=NULL;
  8. +       struct group gr;
  9. +       struct group *retgrptr;
  10. +       char *grbuf;
  11. +       int grbuflen;
  12.         int ret;
  13. -
  14. +   
  15.         if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &group)==FAILURE) {
  16.                WRONG_PARAM_COUNT;
  17.         }
  18.         convert_to_string_ex(filename);
  19.         if (Z_TYPE_PP(group) == IS_STRING) {
  20. -              gr = getgrnam(Z_STRVAL_PP(group));
  21. -              if (!gr) {
  22. +              grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
  23. +              grbuf = emalloc(grbuflen);
  24. +              ret = getgrnam_r(Z_STRVAL_PP(group), &gr, grbuf, grbuflen, &retgrptr);
  25. +              /* If an error or entry not found */
  26. +              if (ret != 0 || retgrptr == NULL ) {
  27.                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s",
  28.                                        Z_STRVAL_PP(group));
  29. +                     efree(grbuf);
  30.                       RETURN_FALSE;
  31.                }
  32. -              gid = gr->gr_gid;
  33. +              gid = gr.gr_gid;
  34. +              efree(grbuf);
  35.         } else {
  36.                convert_to_long_ex(group);
  37.                gid = Z_LVAL_PP(group);
  38. @@ -434,20 +442,29 @@
  39.         zval **filename, **user;
  40.         int ret;
  41.         uid_t uid;
  42. -       struct passwd *pw = NULL;
  43. -
  44. +       struct passwd pw;
  45. +       struct passwd *retpwptr;
  46. +       char *pwbuf;
  47. +       int pwbuflen;
  48. +   
  49.         if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &user)==FAILURE) {
  50.                WRONG_PARAM_COUNT;
  51.         }
  52.         convert_to_string_ex(filename);
  53.         if (Z_TYPE_PP(user) == IS_STRING) {
  54. -              pw = getpwnam(Z_STRVAL_PP(user));
  55. -              if (!pw) {
  56. +
  57. +              pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
  58. +              pwbuf = emalloc(pwbuflen);
  59. +              ret = getpwnam_r(Z_STRVAL_PP(user), &pw, pwbuf, pwbuflen, &retpwptr);
  60. +              /* If an error or entry not found */
  61. +              if (ret != 0 || retpwptr == NULL) {
  62.                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s",
  63.                                        Z_STRVAL_PP(user));
  64. +                     efree(pwbuf);
  65.                       RETURN_FALSE;
  66.                }
  67. -              uid = pw->pw_uid;
  68. +              uid = pw.pw_uid;
  69. +              efree(pwbuf);
  70.         } else {
  71.                convert_to_long_ex(user);
  72.                uid = Z_LVAL_PP(user);

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right