Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 1997 21:30:05 +0900 (JST)
From:      shigio@wafu.netgate.net
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   misc/4812: ctags(1) write to buffer beyond the end of it.
Message-ID:  <199710200632.GAA16658@wafu.netgate.net>
Resent-Message-ID: <199710201440.HAA26302@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         4812
>Category:       misc
>Synopsis:       ctags(1) write to buffer beyond the end of it.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 20 07:40:00 PDT 1997
>Last-Modified:
>Originator:     Shigio Yamaguchi
>Organization:
Freelance programmer
>Release:        FreeBSD 2.2.2-RELEASE i386
>Environment:

	All environment

>Description:

	Ctags write to buffer beyond the end of it when the source file
	doesn't end with '\n'. It brings segmentation fault.

>How-To-Repeat:

	% echo -n 'main(){}' > main.c
	% ctags -x main.c
	Segmentation fault (core dumped)

>Fix:

	[/usr/src/usr.bin/ctags/print.c]

	*** print.c.org	Mon Oct 20 19:16:43 1997
	--- print.c	Mon Oct 20 19:40:27 1997
	***************
	*** 59,65 ****
		saveftell = ftell(inf);
		(void)fseek(inf, lineftell, L_SET);
		if (xflag)
	! 		for (cp = lbuf; GETC(!=, '\n'); *cp++ = c)
				continue;
		/*
		 * do all processing here, so we don't step through the
	--- 59,65 ----
		saveftell = ftell(inf);
		(void)fseek(inf, lineftell, L_SET);
		if (xflag)
	! 		for (cp = lbuf; GETC(!=, EOF) && c != '\n'; *cp++ = c)
				continue;
		/*
		 * do all processing here, so we don't step through the
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710200632.GAA16658>