summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-01-03 03:20:14 +0000
committerJim Meyering <jim@meyering.net>1997-01-03 03:20:14 +0000
commit635a7c31866c693736eed9c4fcc93814a2924e61 (patch)
treee4995ec0cd1b092a334b71553f30e62161fa5e5c /src
parent42d1927306383f530499e62fe849cdb91f222734 (diff)
downloadcoreutils-635a7c31866c693736eed9c4fcc93814a2924e61.tar.xz
(init_fps): Initialize lines_stored field in three places.
This avoids uninitialized memory reads in close_file.
Diffstat (limited to 'src')
-rw-r--r--src/pr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pr.c b/src/pr.c
index 9446d1fea..d28b41005 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -1076,6 +1076,7 @@ init_fps (int number_of_files, char **av)
if (open_file (*av, p) == 0)
return 1;
init_header (*av, fileno (p->fp));
+ p->lines_stored = 0;
}
else
{
@@ -1086,6 +1087,7 @@ init_fps (int number_of_files, char **av)
p->full_page_printed = FALSE;
++total_files;
init_header ("", -1);
+ p->lines_stored = 0;
}
firstname = p->name;
@@ -1096,6 +1098,7 @@ init_fps (int number_of_files, char **av)
p->fp = firstfp;
p->status = OPEN;
p->full_page_printed = FALSE;
+ p->lines_stored = 0;
}
}
files_ready_to_read = total_files;
@@ -1641,6 +1644,7 @@ init_store_cols (void)
if (line_vector != NULL)
free ((int *) line_vector);
+ /* FIXME: here's where it was allocated. */
line_vector = (int *) xmalloc ((total_lines + 1) * sizeof (int *));
if (end_vector != NULL)
@@ -2232,6 +2236,17 @@ print_stored (COLUMN *p)
int line = p->current_line++;
register char *first = &buff[line_vector[line]];
+ /* FIXME
+ UMR: Uninitialized memory read:
+ * This is occurring while in:
+ print_stored [pr.c:2239]
+ * Reading 4 bytes from 0x5148c in the heap.
+ * Address 0x5148c is 4 bytes into a malloc'd block at 0x51488 of 676 bytes
+ * This block was allocated from:
+ malloc [rtlib.o]
+ xmalloc [xmalloc.c:94]
+ init_store_cols [pr.c:1648]
+ */
register char *last = &buff[line_vector[line + 1]];
pad_vertically = TRUE;