summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorlioux <lioux@FreeBSD.org>2003-05-26 17:12:22 +0000
committerlioux <lioux@FreeBSD.org>2003-05-26 17:12:22 +0000
commit91b14ba77f6d38c2d345e0d3cd4ba89300ae0e8a (patch)
treeda77d3ee3e8cc3417d1a4fa8acfa86af4eed0839 /usr.sbin/pkg_install
parent477bf2ab2318375737a5d705511ae342c3c54c18 (diff)
downloadFreeBSD-src-91b14ba77f6d38c2d345e0d3cd4ba89300ae0e8a.zip
FreeBSD-src-91b14ba77f6d38c2d345e0d3cd4ba89300ae0e8a.tar.gz
pkg_create incorrectly does not add trailing '\n' when it receives
either COMMENT or DESCR from the command line. When a port is installed, one gets both +COMMENT and +DESCR files with a trailing '\n' character. However, +COMMENT does not contain a trailing '\n' when it is installed from a package due to this behavior of pkg_create. Therefore, make sure it behaves exactly the same regardless of where got its information; either command line or files. The modified functions are used by pkg_create. PR: 52097 Reviewed by: bento, kris, portmgr, re, Michael Nottebrock <michaelnottebrock@gmx.net>, Martin Horcicka <horcicka@FreeBSD.cz> Approved by: re (scottl) MFC after: 1 week
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/lib/lib.h1
-rw-r--r--usr.sbin/pkg_install/lib/str.c23
2 files changed, 23 insertions, 1 deletions
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index b7ca695..afa68af 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -147,6 +147,7 @@ off_t min_free(const char *);
/* String */
char *get_dash_string(char **);
char *copy_string(const char *);
+char *copy_string_adds_newline(const char *);
Boolean suffix(const char *, const char *);
void nuke_suffix(char *);
void str_lowercase(char *);
diff --git a/usr.sbin/pkg_install/lib/str.c b/usr.sbin/pkg_install/lib/str.c
index 8f6aec3..0d9e288 100644
--- a/usr.sbin/pkg_install/lib/str.c
+++ b/usr.sbin/pkg_install/lib/str.c
@@ -42,7 +42,7 @@ get_dash_string(char **str)
char *s = *str;
if (*s == '-')
- *str = copy_string(s + 1);
+ *str = copy_string_adds_newline(s + 1);
else
*str = fileGetContents(s);
return *str;
@@ -55,6 +55,27 @@ copy_string(const char *str)
return (str ? strdup(str) : NULL);
}
+/* Rather Obvious but adds a trailing \n newline */
+char *
+copy_string_adds_newline(const char *str)
+{
+ if (str == NULL) {
+ return (NULL);
+ } else {
+ char *copy;
+ size_t line_length;
+
+ line_length = strlen(str) + 2;
+ if ((copy = malloc(line_length)) == NULL)
+ return (NULL);
+ memcpy(copy, str, line_length - 2);
+ copy[line_length - 2] = '\n'; /* Adds trailing \n */
+ copy[line_length - 1] = '\0';
+
+ return (copy);
+ }
+}
+
/* Return TRUE if 'str' ends in suffix 'suff' */
Boolean
suffix(const char *str, const char *suff)
OpenPOWER on IntegriCloud