bug parsing quoted strings?

GG
Gustavo Garcia Bernardo
Mon, Jul 16, 2012 12:21 AM

From my understanding this account id should be valid although I'm getting
a PJSIP_EINVALIDURI error: '"ggb\" sip:ggb@tid.es'

But if I add a character before the ending quote it is accepted: '"ggb\a"
sip:ggb@tid.es'

I think the problem is in pjlib-util/src/pjlib-util/scanner.c:

char *q = s-2;
                    char *r = s-2;

                    while (r != scanner->begin && *r == '\\') {
                        --r;
                    }
                    /* break from main loop if we have odd number of backslashes */
                    if (((unsigned)(q-r) & 0x01) == 1) {

Perhaps q and r should be initialized to s-1 instead of s-2 to take into
account all the slashes?

Any idea is more than welcomed,
G.


Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at.
http://www.tid.es/ES/PAGINAS/disclaimer.aspx

From my understanding this account id should be valid although I'm getting a PJSIP_EINVALIDURI error: '"ggb\\" <sip:ggb@tid.es>' But if I add a character before the ending quote it is accepted: '"ggb\\a" <sip:ggb@tid.es>' I think the problem is in pjlib-util/src/pjlib-util/scanner.c: ``` char *q = s-2; char *r = s-2; while (r != scanner->begin && *r == '\\') { --r; } /* break from main loop if we have odd number of backslashes */ if (((unsigned)(q-r) & 0x01) == 1) { ``` Perhaps q and r should be initialized to s-1 instead of s-2 to take into account all the slashes? Any idea is more than welcomed, G. ________________________________ Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo. This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at. http://www.tid.es/ES/PAGINAS/disclaimer.aspx
M
Ming
Wed, Jul 18, 2012 10:21 AM

Hi Gustavio,

Thanks for the report. We just fixed this in #1558
(https://trac.pjsip.org/repos/ticket/1558).

Best regards,
Ming

On Mon, Jul 16, 2012 at 8:21 AM, Gustavo Garcia Bernardo ggb@tid.es wrote:

From my understanding this account id should be valid although I'm getting
a PJSIP_EINVALIDURI error: '"ggb\" sip:ggb@tid.es'

But if I add a character before the ending quote it is accepted: '"ggb\a"
sip:ggb@tid.es'

I think the problem is in pjlib-util/src/pjlib-util/scanner.c:

char *q = s-2;
                    char *r = s-2;

                    while (r != scanner->begin && *r == '\\') {
                        --r;
                    }
                    /* break from main loop if we have odd number of backslashes */
                    if (((unsigned)(q-r) & 0x01) == 1) {

Perhaps q and r should be initialized to s-1 instead of s-2 to take into
account all the slashes?

Any idea is more than welcomed,
G.


Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at.
http://www.tid.es/ES/PAGINAS/disclaimer.aspx


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Gustavio, Thanks for the report. We just fixed this in #1558 (https://trac.pjsip.org/repos/ticket/1558). Best regards, Ming On Mon, Jul 16, 2012 at 8:21 AM, Gustavo Garcia Bernardo <ggb@tid.es> wrote: > From my understanding this account id should be valid although I'm getting > a PJSIP_EINVALIDURI error: '"ggb\\" <sip:ggb@tid.es>' > > But if I add a character before the ending quote it is accepted: '"ggb\\a" > <sip:ggb@tid.es>' > > I think the problem is in pjlib-util/src/pjlib-util/scanner.c: > > ``` > char *q = s-2; > char *r = s-2; > > while (r != scanner->begin && *r == '\\') { > --r; > } > /* break from main loop if we have odd number of backslashes */ > if (((unsigned)(q-r) & 0x01) == 1) { > ``` > > > Perhaps q and r should be initialized to s-1 instead of s-2 to take into > account all the slashes? > > > Any idea is more than welcomed, > G. > > > ________________________________ > > Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo. > This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at. > http://www.tid.es/ES/PAGINAS/disclaimer.aspx > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org