[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pkg_info bug
hello,
i checked the patch to /cvs/src/usr.sbin/pkg_install/info/show.c applied
by Marco S Hyman that absolutely matches one advised in the message pasted
below. well, i may be misuderstand something, but i think there should be
test for line_length is not equal to zero, if it is the next reference to
line[-1] will cause problems. ok, it should be rare case when this may
happen, but i guess, resolving old problems we shouldn't create newer
ones, should we? btw, fgets/strlen are not the best "twix", since their
result not always corresponds to reality.
weird, in same file (show.c) different functions use differnt subrotines
for file reading: show_file() (line 64) uses fread() and show_index()
(line 85) uses fgets() ... to do the same (display content of file)?
--
CYXOB
==============================================================================
--- show.c.orig Tue Mar 9 09:00:17 1999
+++ show.c Tue Mar 9 09:03:14 1999
@@ -99,6 +99,10 @@
if (fgets(line, MAXINDEXSIZE+1, fp)) {
int line_length = strlen(line);
+ if ( !line_length ) {
+ line[0] = '\n'; line[1] = 0;
+ }
+ else
if (line[line_length-1] != '\n') {
line[line_length] = '\n';
line[line_length+1] = 0;
==============================================================================
On Sun, 7 Mar 1999, WHS wrote:
> Date: Sun, 07 Mar 1999 22:37:15 +0100
> From: WHS <wouters@cistron.nl>
> Subject: pkg_info bug
>
> L.S.
>
> When making a port a discovered that COMMENT has to end with a lf, or
> else pkg_info will print the info for the next package on the same line.
> I don't like this as COMMENT is a single line, so I checked
> /usr/src/usr.sbin/pkg_install/info/show.c:
>
>
> At line 97 is this code:
>
> if (fgets(line, MAXINDEXSIZE+1, fp)) {
> if (line[MAXINDEXSIZE-1] != '\n') {
> line[MAXINDEXSIZE] = '\n';
> }
> line[MAXINDEXSIZE+1] = 0;
> (void) fputs(line, stdout);
> }
>
> This should be:
>
> if (fgets(line, MAXINDEXSIZE+1, fp)) {
> int line_length = strlen(line);
>
> if (line[line_length-1] != '\n') {
> line[line_length] = '\n';
> line[line_length+1] = 0;
> }
> (void) fputs(line, stdout);
> }
>
> For convenience I've attached a diff.
>
> (Note: I'm using a mostly stock obsd 2.4 i386)
>
> --
>
> Wouter
>
> GSI (pcm/midi/cd/mixer), GGI, descent: http://www.cistron.nl/~wouters/
>