[asterisk-commits] russell: branch 1.4 r101818 - /branches/1.4/apps/app_authenticate.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 1 11:23:48 CST 2008


Author: russell
Date: Fri Feb  1 11:23:47 2008
New Revision: 101818

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101818
Log:
Don't overwrite the last character of a line if it's not a newline.  This would
happen if the last line in the file doesn't have a newline.
(pointed out by Qwell)

Modified:
    branches/1.4/apps/app_authenticate.c

Modified: branches/1.4/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_authenticate.c?view=diff&rev=101818&r1=101817&r2=101818
==============================================================================
--- branches/1.4/apps/app_authenticate.c (original)
+++ branches/1.4/apps/app_authenticate.c Fri Feb  1 11:23:47 2008
@@ -169,7 +169,9 @@
 					while (!feof(f)) {
 						fgets(buf, sizeof(buf), f);
 						if (!feof(f) && !ast_strlen_zero(buf)) {
-							buf[strlen(buf) - 1] = '\0';
+							size_t len = strlen(buf);
+							if (buf[len] == '\n')
+								buf[len] = '\0';
 							if (ast_test_flag(&flags,OPT_MULTIPLE)) {
 								md5secret = strchr(buf, ':');
 								if (md5secret == NULL)




More information about the asterisk-commits mailing list