You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2005/05/16 02:18:20 UTC
svn commit: r170286 - in /httpd/apreq/trunk/glue/perl/xsbuilder:
APR/Request/Cookie/APR__Request__Cookie.h APR/Request/Cookie/Cookie.xs
maps/apreq_structures.map
Author: joes
Date: Sun May 15 17:18:19 2005
New Revision: 170286
URL: http://svn.apache.org/viewcvs?rev=170286&view=rev
Log:
Fix the domain/path bug. The problem is that EU::XSB generates
unsafe glue for char * attributes. We need to make a pool copy
of the SV when setting domain/path; you can't just do a pointer
assignment here.
Modified:
httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/APR__Request__Cookie.h
httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_structures.map
Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/APR__Request__Cookie.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/APR__Request__Cookie.h?rev=170286&r1=170285&r2=170286&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/APR__Request__Cookie.h (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/APR__Request__Cookie.h Sun May 15 17:18:19 2005
@@ -180,3 +180,19 @@
(void)items;
XSRETURN_EMPTY;
}
+
+static APR_INLINE
+char *apreq_xs_cookie_pool_copy(pTHX_ SV *obj, SV *value)
+{
+ IV iv;
+ STRLEN vlen;
+ char *v;
+ MAGIC *mg;
+ apr_pool_t *p;
+
+ v = SvPV(value, vlen);
+ mg = mg_find(obj, PERL_MAGIC_ext);
+ iv = SvIVX(mg->mg_obj);
+ p = INT2PTR(apr_pool_t *, iv);
+ return apr_pstrmemdup(p, v, vlen);
+}
Modified: httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs?rev=170286&r1=170285&r2=170286&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs Sun May 15 17:18:19 2005
@@ -106,24 +106,126 @@
OUTPUT:
RETVAL
+char *
+path(cookie, path=NULL)
+ SV *cookie
+ SV *path
+
+ PREINIT:
+ apreq_cookie_t *c;
+ SV *obj;
+ IV iv;
+
+ CODE:
+ obj = apreq_xs_sv2object(aTHX_ cookie, COOKIE_CLASS, 'c');
+ iv = SvIVX(obj);
+ c = INT2PTR(apreq_cookie_t *, iv);
+
+ RETVAL = c->path;
+ if (items == 2)
+ c->path = apreq_xs_cookie_pool_copy(aTHX_ obj, path);
+ if (RETVAL == NULL)
+ XSRETURN_UNDEF;
+
+ OUTPUT:
+ RETVAL
+
+char *
+domain(cookie, domain=NULL)
+ SV *cookie
+ SV *domain
-SV*
-bind_handle(cookie, req)
+ PREINIT:
+ apreq_cookie_t *c;
+ SV *obj;
+ IV iv;
+
+ CODE:
+ obj = apreq_xs_sv2object(aTHX_ cookie, COOKIE_CLASS, 'c');
+ iv = SvIVX(obj);
+ c = INT2PTR(apreq_cookie_t *, iv);
+
+ RETVAL = c->domain;
+ if (items == 2)
+ c->domain = apreq_xs_cookie_pool_copy(aTHX_ obj, domain);
+ if (RETVAL == NULL)
+ XSRETURN_UNDEF;
+
+ OUTPUT:
+ RETVAL
+
+char *
+port(cookie, port=NULL)
SV *cookie
- SV *req
+ SV *port
+
PREINIT:
- MAGIC *mg;
+ apreq_cookie_t *c;
SV *obj;
+ IV iv;
+
CODE:
obj = apreq_xs_sv2object(aTHX_ cookie, COOKIE_CLASS, 'c');
- mg = mg_find(obj, PERL_MAGIC_ext);
- req = apreq_xs_sv2object(aTHX_ req, HANDLE_CLASS, 'r');
- RETVAL = newRV_noinc(mg->mg_obj);
- SvREFCNT_inc(req);
- mg->mg_obj = req;
+ iv = SvIVX(obj);
+ c = INT2PTR(apreq_cookie_t *, iv);
+
+ RETVAL = c->port;
+ if (items == 2)
+ c->port = apreq_xs_cookie_pool_copy(aTHX_ obj, port);
+ if (RETVAL == NULL)
+ XSRETURN_UNDEF;
OUTPUT:
RETVAL
+
+char *
+comment(cookie, comment=NULL)
+ SV *cookie
+ SV *comment
+
+ PREINIT:
+ apreq_cookie_t *c;
+ SV *obj;
+ IV iv;
+
+ CODE:
+ obj = apreq_xs_sv2object(aTHX_ cookie, COOKIE_CLASS, 'c');
+ iv = SvIVX(obj);
+ c = INT2PTR(apreq_cookie_t *, iv);
+
+ RETVAL = c->comment;
+ if (items == 2)
+ c->comment = apreq_xs_cookie_pool_copy(aTHX_ obj, comment);
+ if (RETVAL == NULL)
+ XSRETURN_UNDEF;
+
+ OUTPUT:
+ RETVAL
+
+char *
+commentURL(cookie, commentURL=NULL)
+ SV *cookie
+ SV *commentURL
+
+ PREINIT:
+ apreq_cookie_t *c;
+ SV *obj;
+ IV iv;
+
+ CODE:
+ obj = apreq_xs_sv2object(aTHX_ cookie, COOKIE_CLASS, 'c');
+ iv = SvIVX(obj);
+ c = INT2PTR(apreq_cookie_t *, iv);
+
+ RETVAL = c->commentURL;
+ if (items == 2)
+ c->commentURL = apreq_xs_cookie_pool_copy(aTHX_ obj, commentURL);
+ if (RETVAL == NULL)
+ XSRETURN_UNDEF;
+
+ OUTPUT:
+ RETVAL
+
APR::Request::Cookie
Modified: httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_structures.map
URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_structures.map?rev=170286&r1=170285&r2=170286&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_structures.map (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_structures.map Sun May 15 17:18:19 2005
@@ -18,11 +18,11 @@
</apreq_handle_t>
<apreq_cookie_t MODULE=APR::Request::Cookie>
- path
- domain
- port
- comment
- commentURL
+! path
+! domain
+! port
+! comment
+! commentURL
! max_age
! flags
! v
Re: svn commit: r170286 - in /httpd/apreq/trunk/glue/perl/xsbuilder:
APR/Request/Cookie/APR__Request__Cookie.h APR/Request/Cookie/Cookie.xs
maps/apreq_structures.map
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 16 May 2005 joes@apache.org wrote:
> Author: joes
> Date: Sun May 15 17:18:19 2005
> New Revision: 170286
>
> URL: http://svn.apache.org/viewcvs?rev=170286&view=rev
> Log:
> Fix the domain/path bug. The problem is that EU::XSB generates
> unsafe glue for char * attributes. We need to make a pool copy
> of the SV when setting domain/path; you can't just do a pointer
> assignment here.
Nice catch! I was looking at this some this weekend; that's
a subtle bug ...
--
best regards,
randy