The Apache docs readPost causing SIGSEGV

2015-05-18 Thread Vitaliy Kaplenko
Hi,
I am developing a module for Apache that requires parsing form data. As example 
I have used Retrieve variables from POST form data from 
http://httpd.apache.org/docs/2.4/developer/modguide.html#snippets.

When I try to retrieve variables from Post data, in the example row: 
ap_rprintf(r, %s = %s\n, formData[i].key, formData[i].value);

I got:Program received signal SIGSEGV, Segmentation fault.strlen () at 
../sysdeps/x86_64/strlen.S:106106 movdqu (%rax), %xmm12

Is there any way to pass it?Thanks! 

Re: The Apache docs readPost causing SIGSEGV

2015-05-18 Thread Joe Lewis
Please check how you are creating the formData[i].key and format[i].value
fields.  If you are using the POST data in the structure, it is not NULL
terminated.  You have to do your own NULL termination, or (when it reads
out of bounds) you get a SIGSEGV.  Unless you are lucky and have NULL
characters in your own module.

I don't like using the apr_pstrdup, I use the apr_pstrndup form because I
have complete control of size, and I make it one character bigger, and add
a NULL termination to the string JUST to make sure.  I had enough SIGSEGV's
in my life to call it a best practice to make sure the character is there.

Joe

On Mon, May 18, 2015 at 1:45 PM, Vitaliy Kaplenko eps_...@yahoo.com.invalid
 wrote:

 Hi,
 I am developing a module for Apache that requires parsing form data. As
 example I have used Retrieve variables from POST form data from
 http://httpd.apache.org/docs/2.4/developer/modguide.html#snippets.

 When I try to retrieve variables from Post data, in the example
 row: ap_rprintf(r, %s = %s\n, formData[i].key, formData[i].value);

 I got:Program received signal SIGSEGV, Segmentation fault.strlen () at
 ../sysdeps/x86_64/strlen.S:106106 movdqu (%rax), %xmm12

 Is there any way to pass it?Thanks!