summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>1999-03-08 02:01:03 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>1999-03-08 02:01:03 +0000
commitdb3c2c4c2a70ef19a1cd1e1a59d071a4ef85db7b (patch)
tree0e49f605e6787d3d98969148c5e1a41394a2e9e4
parent514916901d81186acd389b2eb81ddeff211f0b03 (diff)
Handle comments that do not end in \n correctly; WHS <wouters@cistron.nl>
-rw-r--r--usr.sbin/pkg_install/info/show.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index 5419bed5aae..2e24c8d8364 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: show.c,v 1.6 1998/11/22 23:22:41 espie Exp $ */
+/* $OpenBSD: show.c,v 1.7 1999/03/08 02:01:02 marc Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: show.c,v 1.6 1998/11/22 23:22:41 espie Exp $";
+static const char *rcsid = "$OpenBSD: show.c,v 1.7 1999/03/08 02:01:02 marc Exp $";
#endif
/*
@@ -97,10 +97,12 @@ show_index(char *title, char *fname)
}
else {
if (fgets(line, MAXINDEXSIZE+1, fp)) {
- if (line[MAXINDEXSIZE-1] != '\n') {
- line[MAXINDEXSIZE] = '\n';
+ int line_length = strlen(line);
+
+ if (line[line_length-1] != '\n') {
+ line[line_length] = '\n';
+ line[line_length+1] = 0;
}
- line[MAXINDEXSIZE+1] = 0;
}
(void) fclose(fp);
}