Welcome! Log In Create A New Profile

Advanced

odd char * arithmetic in nginx binary

October 20, 2010 11:32AM
I'm working on a authentication module and I need to produce a string
without any inherent fixed structure, so I would just using ngx_sprintf and
pointer arithmetic. However something insidious is going on during
compilation. I have played arround with u_char * as well as char *'s. The
gdb debug sessions goes as follows:

-----------------------------------------------------------------------------------------------------------------------
680 char * buf = (char *) ngx_palloc( r->pool, sz);
(gdb) n
681 if ( buf == NULL)
(gdb) n
687 if( parameter_count > 0) {
(gdb) n
688 buf = (char *) ngx_sprintf((u_char *)buf,"%V?", &
alcf->redirect_url);
(gdb) n
690 buf++; buf++;// buf++; buf++; buf++;
(gdb) p buf
$1 = 0x6d2de0 "lala?"
(gdb) n
698 if( parameters[i]->len != 0) {
(gdb) p buf
$2 = 0x6d2de7 ""
-----------------------------------------------------------------------------------------------------------------------

I should see 2 = 0x6d2de2 "la?" as output

I have only incremented the char pointer twice, yet the pointer moves
forward 7 bytes (and when I do a +=5 it moves forward 10 bytes). I am hoping
someone can tell me what is going on here, as t his has
completely flabbergasted me.

Regards

Hassan
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

odd char * arithmetic in nginx binary

hassan.syed 1942 October 20, 2010 11:32AM

Re: odd char * arithmetic in nginx binary

Maxim Dounin 826 October 20, 2010 11:50AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 107
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready