xbps-query: check regcomp() return value.

This commit is contained in:
Juan RP 2014-06-03 12:50:34 +02:00
parent 776865b548
commit a3c253d03c
2 changed files with 11 additions and 5 deletions

View File

@ -73,7 +73,8 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
if (filestr == NULL)
continue;
if (ffd->regex) {
regcomp(&regex, ffd->pat, REG_EXTENDED|REG_NOSUB);
if (regcomp(&regex, ffd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return;
if (regexec(&regex, filestr, 0, 0, 0) == 0) {
printf("%s: %s (%s)\n", pkgver, filestr, typestr);
}
@ -131,7 +132,8 @@ repo_match_cb(struct xbps_handle *xhp _unused,
for (unsigned int i = 0; i < xbps_array_count(obj); i++) {
xbps_array_get_cstring_nocopy(obj, i, &filestr);
if (ffd->regex) {
regcomp(&regex, ffd->pat, REG_EXTENDED|REG_NOSUB);
if (regcomp(&regex, ffd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return errno;
if (regexec(&regex, filestr, 0, 0, 0) == 0) {
printf("%s: %s (%s)\n", key, filestr, ffd->repouri);
}

View File

@ -116,7 +116,9 @@ search_array_cb(struct xbps_handle *xhp _unused,
vpkgfound = true;
if (sd->regex) {
regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB);
if (regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return errno;
if ((regexec(&regex, pkgver, 0, 0, 0) == 0) ||
(regexec(&regex, desc, 0, 0, 0) == 0)) {
xbps_array_add_cstring_nocopy(sd->results, pkgver);
@ -140,7 +142,8 @@ search_array_cb(struct xbps_handle *xhp _unused,
for (unsigned int i = 0; i < xbps_array_count(obj2); i++) {
xbps_array_get_cstring_nocopy(obj2, i, &str);
if (sd->regex) {
regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB);
if (regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return errno;
if (regexec(&regex, str, 0, 0, 0) == 0) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s: %s (%s)\n", pkgver, str, sd->repourl);
@ -162,7 +165,8 @@ search_array_cb(struct xbps_handle *xhp _unused,
/* property is a string */
str = xbps_string_cstring_nocopy(obj2);
if (sd->regex) {
regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB);
if (regcomp(&regex, sd->pat, REG_EXTENDED|REG_NOSUB) != 0)
return errno;
if (regexec(&regex, str, 0, 0, 0) == 0) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s: %s (%s)\n", pkgver, str, sd->repourl);