Ignore comments in INSTALL files (FS#51916)

If a comment in an INSTALL file contains the name of a valid
INSTALL file function but the function itself is not present,
pacman tries to execute that function. That leads to an error.

Ignore comments in the grep function in libalpm/trans.c to
avoid such errors.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Michael Straube 2017-03-25 21:36:50 +01:00 committed by Allan McRae
parent c635f185ba
commit 5678298f7d

View file

@ -305,6 +305,7 @@ void _alpm_trans_free(alpm_trans_t *trans)
static int grep(const char *fn, const char *needle) static int grep(const char *fn, const char *needle)
{ {
FILE *fp; FILE *fp;
char *ptr;
if((fp = fopen(fn, "r")) == NULL) { if((fp = fopen(fn, "r")) == NULL) {
return 0; return 0;
@ -314,6 +315,9 @@ static int grep(const char *fn, const char *needle)
if(safe_fgets(line, sizeof(line), fp) == NULL) { if(safe_fgets(line, sizeof(line), fp) == NULL) {
continue; continue;
} }
if((ptr = strchr(line, '#')) != NULL) {
*ptr = '\0';
}
/* TODO: this will not work if the search string /* TODO: this will not work if the search string
* ends up being split across line reads */ * ends up being split across line reads */
if(strstr(line, needle)) { if(strstr(line, needle)) {