[Asterisk-Dev] Voicemail password changes not sticking
James Armstrong
james at thearmstrongs.org
Thu Nov 10 07:55:45 MST 2005
I finally tracked down a problem we have been having, users have not
been able to change their voicemail passwords and have them stay after a
reload.
The password would be changed in 'realtime', but when the voicemail.conf
file would be re-written, the changes would not be put in. It turned out
to be something I have not been able to explain looking at he C code,
because it looks ok, but here is what was happening:
When reading lines from the voicemail.conf file to match on the Context,
the context name it was parsing would be missing the last digit so the
user would never match and therefore the new password would never be
written. For example, if our context is [harksystems], the parser would
end up with the variable 'currcontext' set to 'harksystem'. The code
looked ok, but I was able to fix it by changing the math of the tmpctx
and tmpctxend when parsing the context from the []'s. Here is the code
from vm_change_password:
if (inbuf[0] != '\0') { /* skip over parsing
for lines starting with a comment character and empty lines */
/* Check for a context, first '[' to
first ']' */
tmpctx = strchr(inbuf, '[');
if (tmpctx) {
tmpctxend = strchr(inbuf, ']');
if (tmpctxend && (tmpctxend >
tmpctx)) {
/* Valid context */
PROBLEM IS WITH THE FOLLOWING TWO LINES:
ast_copy_string(currcontext, tmpctx + 1, tmpctxend - tmpctx-1);
currcontext[tmpctxend - tmpctx - 1] = '\0';
IT WORKS IF I CHANGE TO:
ast_copy_string(currcontext, tmpctx + 1, tmpctxend - tmpctx);
currcontext[tmpctxend - tmpctx] = '\0';
} else {
tmpctx = NULL;
}
}
Like I said, it looks like the tmpctxend-tmpctx-1 is correct, but it
chops off the last character in the context when it is parsed from
between the []'s.
Thanks,
James
More information about the asterisk-dev
mailing list