summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 16:31:00 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2007-09-11 16:31:00 +0000
commita8152da22f218d42cf3e2467c979fd1b1b487943 (patch)
tree56bcdad1b11232f055be50d69dd3cc079d74a75a /usr.sbin/ppp
parent25679492194cdf74e631b94ff0156ca727ed97f0 (diff)
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ppp/auth.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/usr.sbin/ppp/ppp/auth.c b/usr.sbin/ppp/ppp/auth.c
index d24da995a89..1db1ea85d9f 100644
--- a/usr.sbin/ppp/ppp/auth.c
+++ b/usr.sbin/ppp/ppp/auth.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: auth.c,v 1.20 2006/11/02 18:27:29 ray Exp $
+ * $OpenBSD: auth.c,v 1.21 2007/09/11 16:30:59 gilles Exp $
*/
#include <sys/param.h>
@@ -124,13 +124,10 @@ auth_SetPhoneList(const char *name, char *phone, int phonelen)
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -188,13 +185,10 @@ auth_Select(struct bundle *bundle, const char *name)
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -259,13 +253,10 @@ again:
lineno = 0;
if (fp != NULL) {
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
@@ -317,14 +308,11 @@ auth_GetSecret(struct bundle *bundle, const char *name, int len,
again:
lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
- char *p;
-
lineno++;
if (buff[0] == '#')
continue;
/* Trim the '\n' */
- if ((p = strchr(buff, '\n')) != NULL)
- *p = '\0';
+ buff[strcspn(buff, "\n")] = '\0';
memset(vector, '\0', sizeof vector);
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);