Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package mcstrans for openSUSE:Factory 
checked in at 2022-06-20 15:36:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mcstrans (Old)
 and      /work/SRC/openSUSE:Factory/.mcstrans.new.1548 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mcstrans"

Mon Jun 20 15:36:46 2022 rev:30 rq:978301 version:3.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/mcstrans/mcstrans.changes        2021-11-28 
21:30:09.542066563 +0100
+++ /work/SRC/openSUSE:Factory/.mcstrans.new.1548/mcstrans.changes      
2022-06-20 15:36:51.850823408 +0200
@@ -1,0 +2,9 @@
+Mon May  9 10:49:13 UTC 2022 - Johannes Segitz <jseg...@suse.com>
+
+- Update to version 3.4
+  * Port to PCRE2
+- Dropped patches
+  * add_includes.patch: Upstream
+  * mcstrans-writepid.patch: Upstream
+
+-------------------------------------------------------------------

Old:
----
  add_includes.patch
  mcstrans-3.3.tar.gz
  mcstrans-writepid.patch

New:
----
  mcstrans-3.4.tar.gz
  mcstrans-3.4.tar.gz.asc
  mcstrans.keyring

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mcstrans.spec ++++++
--- /var/tmp/diff_new_pack.glgdmM/_old  2022-06-20 15:36:52.518824386 +0200
+++ /var/tmp/diff_new_pack.glgdmM/_new  2022-06-20 15:36:52.522824391 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package mcstrans
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,15 +17,15 @@
 
 
 Name:           mcstrans
-Version:        3.3
+Version:        3.4
 Release:        0
 Summary:        SELinux Translation Daemon
 License:        GPL-2.0-or-later
 Group:          System/Management
 URL:            https://github.com/SELinuxProject/selinux/wiki
-Source:         
https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz
-Patch0:         %{name}-writepid.patch
-Patch1:         add_includes.patch
+Source0:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz
+Source1:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz.asc
+Source2:        mcstrans.keyring
 Patch2:         harden_mcstrans.service.patch
 BuildRequires:  aaa_base
 BuildRequires:  libcap-devel
@@ -53,8 +53,6 @@
 
 %prep
 %setup -q
-%patch0 -p1
-%patch1 -p1
 %patch2 -p1
 
 %build

++++++ mcstrans-3.3.tar.gz -> mcstrans-3.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/Makefile new/mcstrans-3.4/Makefile
--- old/mcstrans-3.3/Makefile   2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/Makefile   2022-05-18 16:51:03.000000000 +0200
@@ -1,3 +1,9 @@
+PKG_CONFIG ?= pkg-config
+PCRE_MODULE := libpcre2-8
+PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PCRE_MODULE)) 
-DPCRE2_CODE_UNIT_WIDTH=8
+PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PCRE_MODULE))
+export PCRE_MODULE PCRE_CFLAGS PCRE_LDLIBS
+
 all: 
        $(MAKE) -C src 
        $(MAKE) -C utils
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/VERSION new/mcstrans-3.4/VERSION
--- old/mcstrans-3.3/VERSION    2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/VERSION    2022-05-18 16:51:03.000000000 +0200
@@ -1 +1 @@
-3.3
+3.4
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/Makefile 
new/mcstrans-3.4/src/Makefile
--- old/mcstrans-3.3/src/Makefile       2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/src/Makefile       2022-05-18 16:51:03.000000000 +0200
@@ -20,10 +20,10 @@
 all: $(PROG)
 
 $(PROG): $(PROG_OBJS) $(LIBSEPOLA)
-       $(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre 
$(LDLIBS_LIBSEPOLA)
+       $(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap $(PCRE_LDLIBS) 
$(LDLIBS_LIBSEPOLA)
 
 %.o:  %.c 
-       $(CC) $(CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o $@ $<
+       $(CC) $(CFLAGS) $(PCRE_CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 
-fPIE -c -o $@ $<
 
 install: all
        test -d $(DESTDIR)$(SBINDIR) || install -m 755 -d $(DESTDIR)$(SBINDIR)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/mcscolor.c 
new/mcstrans-3.4/src/mcscolor.c
--- old/mcstrans-3.3/src/mcscolor.c     2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/src/mcscolor.c     2022-05-18 16:51:03.000000000 +0200
@@ -11,6 +11,8 @@
 #include <syslog.h>
 #include <selinux/selinux.h>
 #include <selinux/context.h>
+
+#include "mcscolor.h"
 #include "mcstrans.h"
 
 /* Define data structures */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/mcscolor.h 
new/mcstrans-3.4/src/mcscolor.h
--- old/mcstrans-3.3/src/mcscolor.h     1970-01-01 01:00:00.000000000 +0100
+++ new/mcstrans-3.4/src/mcscolor.h     2022-05-18 16:51:03.000000000 +0200
@@ -0,0 +1,8 @@
+#ifndef __mcscolor_h__
+#define __mcscolor_h__
+
+extern void finish_context_colors(void);
+extern int init_colors(void);
+extern int raw_color(const char *raw, char **color_str);
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/mcstrans.c 
new/mcstrans-3.4/src/mcstrans.c
--- old/mcstrans-3.3/src/mcstrans.c     2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/src/mcstrans.c     2022-05-18 16:51:03.000000000 +0200
@@ -26,7 +26,7 @@
 #include <selinux/context.h>
 #include <syslog.h>
 #include <errno.h>
-#include <pcre.h>
+#include <pcre2.h>
 #include <ctype.h>
 #include <time.h>
 #include <sys/time.h>
@@ -36,7 +36,6 @@
 #include "mcstrans.h"
 
 #define N_BUCKETS 1453
-#define OVECCOUNT (512*3)
 
 #define log_error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
 
@@ -82,9 +81,9 @@
        affix_t *suffixes;
        word_t *words;
 
-       pcre *prefix_regexp;
-       pcre *word_regexp;
-       pcre *suffix_regexp;
+       pcre2_code *prefix_regexp;
+       pcre2_code *word_regexp;
+       pcre2_code *suffix_regexp;
 
        ebitmap_t def;
 
@@ -109,7 +108,7 @@
        base_classification_t *base_classifications;
        word_group_t *groups;
 
-       pcre *base_classification_regexp;
+       pcre2_code *base_classification_regexp;
        struct domain *next;
 } domain_t;
 
@@ -136,7 +135,7 @@
 
 static cat_constraint_t *cat_constraints;
 
-unsigned int
+static unsigned int
 hash(const char *str) {
        unsigned int hash = 5381;
        int c;
@@ -213,7 +212,7 @@
        return 0;
 }
 
-int
+static int
 parse_ebitmap(ebitmap_t *e, ebitmap_t *def, const char *raw) {
        int rc = ebitmap_cpy(e, def);
        if (rc < 0)
@@ -224,7 +223,7 @@
        return 0;
 }
 
-mls_level_t *
+static mls_level_t *
 parse_raw(const char *raw) {
        mls_level_t *mls = calloc(1, sizeof(mls_level_t));
        if (!mls)
@@ -248,7 +247,7 @@
        return NULL;
 }
 
-void
+static void
 destroy_word(word_t **list, word_t *word) {
        if (!word) {
                return;
@@ -267,7 +266,7 @@
        free(word);
 }
 
-word_t *
+static word_t *
 create_word(word_t **list, const char *text) {
        word_t *w = calloc(1, sizeof(word_t));
        if (!w) {
@@ -291,7 +290,7 @@
        return NULL;
 }
 
-void
+static void
 destroy_group(word_group_t **list, word_group_t *group) {
        for (; list && *list; list = &(*list)->next) {
                if (*list == group) {
@@ -317,14 +316,14 @@
        free(group->name);
        free(group->sword);
        free(group->join);
-       pcre_free(group->prefix_regexp);
-       pcre_free(group->word_regexp);
-       pcre_free(group->suffix_regexp);
+       pcre2_code_free(group->prefix_regexp);
+       pcre2_code_free(group->word_regexp);
+       pcre2_code_free(group->suffix_regexp);
        ebitmap_destroy(&group->def);
        free(group);
 }
 
-word_group_t *
+static word_group_t *
 create_group(word_group_t **list, const char *name) {
        word_group_t *group = calloc(1, sizeof(word_group_t));
        if (!group)
@@ -357,7 +356,7 @@
        return NULL;
 }
 
-void
+static void
 destroy_domain(domain_t *domain) {
        int i;
         unsigned int rt = 0, tr = 0;
@@ -392,7 +391,7 @@
                free(domain->base_classifications);
                domain->base_classifications = next;
        }
-       pcre_free(domain->base_classification_regexp);
+       pcre2_code_free(domain->base_classification_regexp);
        while (domain->groups)
                destroy_group(&domain->groups, domain->groups);
        free(domain->name);
@@ -401,7 +400,7 @@
        syslog(LOG_INFO, "cache sizes: tr = %u, rt = %u", tr, rt);
 }
 
-domain_t *
+static domain_t *
 create_domain(const char *name) {
        domain_t *domain = calloc(1, sizeof(domain_t));
        if (!domain) {
@@ -425,7 +424,7 @@
        return NULL;
 }
 
-int
+static int
 add_word(word_group_t *group, char *raw, char *trans) {
        if (strchr(trans,'-')) {
                log_error("'%s'is invalid because '-' is illegal in 
modifiers.\n", trans);
@@ -451,7 +450,7 @@
        return 0;
 }
 
-int
+static int
 add_constraint(char op, char *raw, char *tok) {
        log_debug("%s\n", "add_constraint");
        ebitmap_t empty;
@@ -521,7 +520,7 @@
        return 0;
 }
 
-int
+static int
 violates_constraints(mls_level_t *l) {
        int nbits;
        sens_constraint_t *s;
@@ -563,7 +562,7 @@
        return 0;
 }
 
-void
+static void
 destroy_sens_constraint(sens_constraint_t **list, sens_constraint_t 
*constraint) {
        if (!constraint) {
                return;
@@ -580,7 +579,7 @@
        free(constraint);
 }
 
-void
+static void
 destroy_cat_constraint(cat_constraint_t **list, cat_constraint_t *constraint) {
        if (!constraint) {
                return;
@@ -633,16 +632,23 @@
 
        map->raw = strdup(raw);
        if (!map->raw) {
+               free(map);
                goto err;
        }
        map->trans = strdup(trans);
        if (!map->trans) {
+               free(map->raw);
+               free(map);
                goto err;
        }
 
        log_debug(" add_cache (%s,%s)\n", raw, trans);
-       if (add_to_hashtable(domain->raw_to_trans, map->raw, map) < 0)
+       if (add_to_hashtable(domain->raw_to_trans, map->raw, map) < 0) {
+               free(map->trans);
+               free(map->raw);
+               free(map);
                goto err;
+       }
 
        if (add_to_hashtable(domain->trans_to_raw, map->trans, map) < 0)
                goto err;
@@ -663,7 +669,7 @@
        return NULL;
 }
 
-char *
+static char *
 trim(char *str, const char *whitespace) {
        char *p = str + strlen(str);
 
@@ -672,7 +678,7 @@
        return str;
 }
 
-char *
+static char *
 triml(char *str, const char *whitespace) {
        char *p = str;
 
@@ -681,7 +687,7 @@
        return p;
 }
 
-int
+static int
 update(char **p, char *const val) {
        free (*p);
        *p = strdup(val);
@@ -692,7 +698,7 @@
        return 0;
 }
 
-int
+static int
 append(affix_t **affixes, const char *val) {
        affix_t *affix = calloc(1, sizeof(affix_t));
        if (!affix) {
@@ -887,7 +893,7 @@
        return(read_translations(selinux_translations_path()));
 }
 
-char *
+static char *
 extract_range(const char *incon) {
        context_t con = context_new(incon);
        if (!con) {
@@ -910,7 +916,7 @@
        return r;
 }
 
-char *
+static char *
 new_context_str(const char *incon, const char *range) {
        char *rcon = NULL;
        context_t con = context_new(incon);
@@ -931,7 +937,7 @@
        return NULL;
 }
 
-char *
+static char *
 find_in_hashtable(const char *range, domain_t *domain, context_map_node_t 
**table) {
        char *trans = NULL;
        context_map_t *map = find_in_table(table, range);
@@ -946,13 +952,6 @@
        return trans;
 }
 
-void
-emit_whitespace(char*buffer, char *whitespace) {
-       strcat(buffer, "[");
-       strcat(buffer, whitespace);
-       strcat(buffer, "]");
-}
-
 static int
 string_size(const void *p1, const void *p2) {
        return strlen(*(char **)p2) - strlen(*(char **)p1);
@@ -969,20 +968,22 @@
        return (w2_len - w1_len);
 }
 
-void
-build_regexp(pcre **r, char *buffer) {
-       const char *error;
-       int error_offset;
+static void
+build_regexp(pcre2_code **r, char *buffer) {
+       int error;
+       PCRE2_SIZE error_offset;
        if (*r)
-               pcre_free(*r);
-       *r = pcre_compile(buffer, PCRE_CASELESS, &error, &error_offset, NULL);
-       if (error) {
-               log_error("pcre=%s, error=%s\n", buffer, error ? error: "none");
+               pcre2_code_free(*r);
+       *r = pcre2_compile((PCRE2_SPTR8) buffer, PCRE2_ZERO_TERMINATED, 
PCRE2_CASELESS, &error, &error_offset, NULL);
+       if (!*r) {
+               PCRE2_UCHAR errbuf[256];
+               pcre2_get_error_message(error, errbuf, sizeof(errbuf));
+               log_error("pcre compilation of '%s' failed at offset %zu: 
%s\n", buffer, error_offset, errbuf);
        }
        buffer[0] = '\0';
 }
 
-int
+static int
 build_regexps(domain_t *domain) {
        char buffer[1024 * 128];
        buffer[0] = '\0';
@@ -1086,7 +1087,7 @@
        return 0;
 }
 
-char *
+static char *
 compute_raw_from_trans(const char *level, domain_t *domain) {
 
 #ifdef DEBUG
@@ -1095,12 +1096,12 @@
 #endif
 
        int rc = 0;
-       int ovector[OVECCOUNT];
+       pcre2_match_data *match_data = NULL;
        word_group_t *g = NULL;
        char *work = NULL;
        char *r = NULL;
-       const char * match = NULL;
-       int work_len;
+       char *match = NULL;
+       size_t work_len;
        mls_level_t *mraw = NULL;
        ebitmap_t set, clear, tmp;
 
@@ -1121,11 +1122,20 @@
        if (!domain->base_classification_regexp)
                goto err;
        log_debug(" compute_raw_from_trans work = %s\n", work);
-       rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 
0, PCRE_ANCHORED, ovector, OVECCOUNT);
+       match_data = 
pcre2_match_data_create_from_pattern(domain->base_classification_regexp, NULL);
+       if (!match_data) {
+               log_error("allocation error %s", strerror(errno));
+               goto err;
+       }
+       rc = pcre2_match(domain->base_classification_regexp, (PCRE2_SPTR8)work, 
work_len, 0, PCRE2_ANCHORED, match_data, NULL);
        if (rc > 0) {
-               match = NULL;
-               pcre_get_substring(work, ovector, rc, 0, &match);
-               log_debug(" compute_raw_from_trans match = %s len = %u\n", 
match, strlen(match));
+               const PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer(match_data);
+               match = strndup(work + ovector[0], ovector[1] - ovector[0]);
+               if (!match) {
+                       log_error("allocation error %s", strerror(errno));
+                       goto err;
+               }
+               log_debug(" compute_raw_from_trans match = %s len = %zu\n", 
match, strlen(match));
                base_classification_t *bc;
                for (bc = domain->base_classifications; bc; bc = bc->next) {
                        if (!strcmp(bc->trans, match)) {
@@ -1145,12 +1155,23 @@
                char *p=work + ovector[0] + ovector[1];
                while (*p && (strchr("  ", *p) != NULL))
                        *p++ = '#';
-               pcre_free((char *)match);
+
+               free(match);
                match = NULL;
        } else {
-               log_debug(" compute_raw_from_trans no base classification 
matched %s\n", level);
+               switch (rc) {
+               case PCRE2_ERROR_NOMATCH:
+                       log_debug(" compute_raw_from_trans no base 
classification matched %s\n", level);
+                       break;
+               default:
+                       log_error("compute_raw_from_trans: base matching error 
for input '%s': %d\n", level, rc);
+                       break;
+               }
        }
 
+       pcre2_match_data_free(match_data);
+       match_data = NULL;
+
        if (mraw == NULL) {
                goto err;
        }
@@ -1161,23 +1182,43 @@
                change = 0;
                for (g = domain->groups; g && !change && !complete; g = 
g->next) {
                        int prefix = 0, suffix = 0;
-                       int prefix_offset = 0, prefix_len = 0;
-                       int suffix_offset = 0, suffix_len = 0;
+                       PCRE2_SIZE prefix_offset = 0, prefix_len = 0;
+                       PCRE2_SIZE suffix_offset = 0, suffix_len = 0;
                        if (g->prefix_regexp) {
-                               rc = pcre_exec(g->prefix_regexp, 0, work, 
work_len, 0, 0, ovector, OVECCOUNT);
+                               match_data = 
pcre2_match_data_create_from_pattern(g->prefix_regexp, NULL);
+                               if (!match_data) {
+                                       log_error("allocation error %s", 
strerror(errno));
+                                       goto err;
+                               }
+                               rc = pcre2_match(g->prefix_regexp, 
(PCRE2_SPTR8)work, work_len, 0, 0, match_data, NULL);
                                if (rc > 0) {
+                                       const PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer(match_data);
                                        prefix = 1;
                                        prefix_offset = ovector[0];
                                        prefix_len = ovector[1] - ovector[0];
+                               } else if (rc != PCRE2_ERROR_NOMATCH) {
+                                       log_error("compute_raw_from_trans: 
prefix matching error for input '%s': %d\n", level, rc);
                                }
+                               pcre2_match_data_free(match_data);
+                               match_data = NULL;
                        }
                        if (g->suffix_regexp) {
-                               rc = pcre_exec(g->suffix_regexp, 0, work, 
work_len, 0, 0, ovector, OVECCOUNT);
+                               match_data = 
pcre2_match_data_create_from_pattern(g->suffix_regexp, NULL);
+                               if (!match_data) {
+                                       log_error("allocation error %s", 
strerror(errno));
+                                       goto err;
+                               }
+                               rc = pcre2_match(g->suffix_regexp, 
(PCRE2_SPTR8)work, work_len, 0, 0, match_data, NULL);
                                if (rc > 0) {
+                                       const PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer(match_data);
                                        suffix = 1;
                                        suffix_offset = ovector[0];
                                        suffix_len = ovector[1] - ovector[0];
+                               } else if (rc != PCRE2_ERROR_NOMATCH) {
+                                       log_error("compute_raw_from_trans: 
suffix matching error for input '%s': %d\n", level, rc);
                                }
+                               pcre2_match_data_free(match_data);
+                               match_data = NULL;
                        }
 
 /* anchors prefix ^, suffix $ */
@@ -1186,14 +1227,23 @@
                             (g->suffixes && suffix)) &&
                             g->word_regexp) {
                                char *s = work + prefix_offset + prefix_len;
-                               int l = (suffix_len ? suffix_offset : work_len) 
- prefix_len - prefix_offset;
-                               rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, 
ovector, OVECCOUNT);
+                               PCRE2_SIZE len = (suffix_len ? suffix_offset : 
work_len) - prefix_len - prefix_offset;
+                               match_data = 
pcre2_match_data_create_from_pattern(g->word_regexp, NULL);
+                               if (!match_data) {
+                                       log_error("allocation error %s", 
strerror(errno));
+                                       goto err;
+                               }
+                               rc = pcre2_match(g->word_regexp, 
(PCRE2_SPTR8)s, len, 0, 0, match_data, NULL);
                                if (rc > 0) {
-                                       match = NULL;
-                                       pcre_get_substring(s, ovector, rc, 0, 
&match);
-                                       trim((char *)match, g->whitespace);
+                                       const PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer(match_data);
+                                       match = strndup(s + ovector[0], 
ovector[1] - ovector[0]);
+                                       if (!match) {
+                                               log_error("allocation error 
%s", strerror(errno));
+                                               goto err;
+                                       }
+                                       trim(match, g->whitespace);
                                        if (*match) {
-                                               char *p = triml((char *)match, 
g->whitespace);
+                                               char *p = triml(match, 
g->whitespace);
                                                while (p && *p) {
                                                        int plen = strlen(p);
                                                        unsigned int i;
@@ -1230,9 +1280,13 @@
                                                memset(work + suffix_offset, 
'#', suffix_len);
                                                memset(s + ovector[0], '#', 
ovector[1] - ovector[0]);
                                        }
-                                       pcre_free((void *)match);
+                                       free(match);
                                        match = NULL;
+                               } else if (rc != PCRE2_ERROR_NOMATCH) {
+                                       log_error("compute_raw_from_trans: word 
matching error for input '%s' for substring '%s': %d\n", level, s, rc);
                                }
+                               pcre2_match_data_free(match_data);
+                               match_data = NULL;
                        }
 /* YYY */
                        complete=1;
@@ -1271,14 +1325,15 @@
        mls_level_destroy(mraw);
        free(mraw);
        free(work);
-       pcre_free((void *)match);
+       free(match);
        ebitmap_destroy(&tmp);
        ebitmap_destroy(&set);
        ebitmap_destroy(&clear);
+       pcre2_match_data_free(match_data);
        return NULL;
 }
 
-char *
+static char *
 compute_trans_from_raw(const char *level, domain_t *domain) {
 
 #ifdef DEBUG
@@ -1520,6 +1575,7 @@
                        trans = compute_trans_from_raw(range, domain);
                        if (trans)
                                if (add_cache(domain, range, trans) < 0) {
+                                       free(trans);
                                        free(range);
                                        return -1;
                                }
@@ -1531,6 +1587,7 @@
                                ltrans = compute_trans_from_raw(lrange, domain);
                                if (ltrans) {
                                        if (add_cache(domain, lrange, ltrans) < 
0) {
+                                               free(ltrans);
                                                free(range);
                                                return -1;
                                        }
@@ -1549,6 +1606,7 @@
                                utrans = compute_trans_from_raw(urange, domain);
                                if (utrans) {
                                        if (add_cache(domain, urange, utrans) < 
0) {
+                                               free(utrans);
                                                free(ltrans);
                                                free(range);
                                                return -1;
@@ -1588,6 +1646,10 @@
                }
                if (dashp)
                        *dashp = '-';
+               if (trans) {
+                       free(trans);
+                       trans = NULL;
+               }
        }
 
        if (trans) {
@@ -1648,7 +1710,9 @@
                                        canonical = compute_trans_from_raw(raw, 
domain);
                                        if (canonical && strcmp(canonical, 
range))
                                                if (add_cache(domain, raw, 
canonical) < 0) {
+                                                       free(canonical);
                                                        free(range);
+                                                       free(raw);
                                                        return -1;
                                                }
                                }
@@ -1656,6 +1720,7 @@
                                        free(canonical);
                                if (add_cache(domain, raw, range) < 0) {
                                        free(range);
+                                       free(raw);
                                        return -1;
                                }
                        } else {
@@ -1673,6 +1738,7 @@
                                                canonical = 
compute_trans_from_raw(lraw, domain);
                                                if (canonical)
                                                        if (add_cache(domain, 
lraw, canonical) < 0) {
+                                                               free(canonical);
                                                                free(lraw);
                                                                free(range);
                                                                return -1;
@@ -1704,6 +1770,7 @@
                                                canonical = 
compute_trans_from_raw(uraw, domain);
                                                if (canonical)
                                                        if (add_cache(domain, 
uraw, canonical) < 0) {
+                                                               free(canonical);
                                                                free(uraw);
                                                                free(lraw);
                                                                free(range);
@@ -1754,6 +1821,10 @@
                }
                if (dashp)
                        *dashp = '-';
+               if (raw) {
+                       free(raw);
+                       raw = NULL;
+               }
        }
 
        if (raw) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/mcstrans.h 
new/mcstrans-3.4/src/mcstrans.h
--- old/mcstrans-3.3/src/mcstrans.h     2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/src/mcstrans.h     2022-05-18 16:51:03.000000000 +0200
@@ -6,4 +6,3 @@
 extern void finish_context_translations(void);
 extern int trans_context(const char *, char **);
 extern int untrans_context(const char *, char **);
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/src/mcstransd.c 
new/mcstrans-3.4/src/mcstransd.c
--- old/mcstrans-3.3/src/mcstransd.c    2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/src/mcstransd.c    2022-05-18 16:51:03.000000000 +0200
@@ -16,6 +16,8 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <sys/un.h>
+
+#include "mcscolor.h"
 #include "mcstrans.h"
 
 #ifdef UNUSED
@@ -43,15 +45,6 @@
 #define log_debug(fmt, ...) do {} while (0)
 #endif
 
-extern int init_translations(void);
-extern void finish_context_translations(void);
-extern int trans_context(const char *, char **);
-extern int untrans_context(const char *, char **);
-
-extern int init_colors(void);
-extern void finish_context_colors(void);
-extern int raw_color(const char *, char **);
-
 #define SETRANSD_PATHNAME "/sbin/mcstransd"
 
 /* name of program (for error messages) */
@@ -335,6 +328,7 @@
                                        /* Setup pollfd for deletion later. */
                                        (*ufds)[ii].fd = -1;
                                        close(connfd);
+                                       connfd = -1;
                                        /* So we don't get bothered later */
                                        revents = revents & ~(POLLHUP);
                                }
@@ -348,10 +342,11 @@
                        /* Set the pollfd up for deletion later. */
                        (*ufds)[ii].fd = -1;
                        close(connfd);
+                       connfd = -1;
 
                        revents = revents & ~(POLLHUP);
                }
-               if (revents) {
+               if (revents && connfd != -1) {
                        syslog(LOG_ERR, "Unknown/error events (%x) encountered"
                                        " for fd (%d)\n", revents, connfd);
 
@@ -514,7 +509,7 @@
 
 }
 
-void dropprivs(void)
+static void dropprivs(void)
 {
        cap_t new_caps;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mcstrans-3.3/utils/Makefile 
new/mcstrans-3.4/utils/Makefile
--- old/mcstrans-3.3/utils/Makefile     2021-10-21 16:31:23.000000000 +0200
+++ new/mcstrans-3.4/utils/Makefile     2022-05-18 16:51:03.000000000 +0200
@@ -14,13 +14,13 @@
 all: $(TARGETS)
 
 transcon: transcon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
-       $(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+       $(CC) $(LDFLAGS) -o $@ $^ $(PCRE_LDLIBS) -lselinux $(LDLIBS_LIBSEPOLA)
 
 untranscon: untranscon.o ../src/mcstrans.o ../src/mls_level.o $(LIBSEPOLA)
-       $(CC) $(LDFLAGS) -o $@ $^ -lpcre -lselinux $(LDLIBS_LIBSEPOLA)
+       $(CC) $(LDFLAGS) -o $@ $^ $(PCRE_LDLIBS) -lselinux $(LDLIBS_LIBSEPOLA)
 
 %.o:  %.c 
-       $(CC) $(CFLAGS) -D_GNU_SOURCE -I../src -fPIE -c -o $@ $<
+       $(CC) $(CFLAGS) $(PCRE_CFLAGS) -D_GNU_SOURCE -I../src -fPIE -c -o $@ $<
 
 install: all
        -mkdir -p $(DESTDIR)$(SBINDIR)

Reply via email to