A bug in privacy manager?

I was pulling my hair out. My recent addition to extensions_custom.conf was not working. I’d enter the phone number when prompted, but it would bail out as if I’d entered the wrong number (and had exceeded the number of retries.) Adding a few ast_log statements and perusal of the source code shows the problem:

            /*Ask for 10 digit number, give 3 attempts*/
            for (retries = 0; retries < maxretries; retries++) {
                    if (!res)
                            res = ast_streamfile(chan, "privacy-prompt", chan->language);
                    if (!res)
                            res = ast_waitstream(chan, "");

                    if (!res )
                            res = ast_readstring(chan, phone, sizeof(phone) - 1, /* digit timeout ms */ 3200, /* first digit timeout */ 5000, "#");

                    if (res < 0)

ast_log(LOG_WARNING, “user entered ‘%s’\n”, phone);
ast_log(LOG_WARNING, “strlen(phone) = %d minlength = %d\n”,
strlen(phone), minlength);

                    /*Make sure we get at least digits*/
                    if (strlen(phone) >= minlength ) {
                            res = 0; <=== I added this statement
                    else {
                            res = ast_streamfile(chan, "privacy-incorrect", chan->language);
                            if (!res)
                                    res = ast_waitstream(chan, "");

and later:

            /*Got a number, play sounds and send them on their way*/
            if ((retries < maxretries) && !res ) { <=== this never executes!
                    res = ast_streamfile(chan, "privacy-thankyou", chan->language);                         
                    if (!res)       
                            res = ast_waitstream(chan, "");
                    ast_set_callerid (chan, phone, "Privacy Manager", NULL);

here is why, per the source code for ast_readstring, available from asterisk.org/doxygen/channel_8c.html

RETURNS 2 in full version when ctrlfd is available, NOT 1

and looking at that routine, it can return 0, 1, -1. I could swear I’ve used this in the past, did something break up to 1.2.4? Where does one file bug reports?

sorry about the crappy indentation, the web site did it :smile:

anyway, to clarify, ast_readstring() is returning a 1, which causes the if statement to fail so we bail out as if the caller had exceeded max retries of bad entries…

i think you would post this bug here:



Already known and a fix committed :smile: