Skip to content

Commit

Permalink
[DO NOT MERGE] please pedantic UBSAN
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Aug 10, 2023
1 parent 3b1468f commit c33c9a5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libselinux/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-Werror -Wno-aggregate-return \
$(EXTRA_CFLAGS)

LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro
LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,relro

ifeq ($(OS), Darwin)
override CFLAGS += -I/opt/local/include
Expand Down
7 changes: 5 additions & 2 deletions libselinux/src/label.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ static inline struct selabel_digest *selabel_is_digest_set
{
struct selabel_digest *digest = NULL;

while (n--) {
while (n) {
n--;
if (opts[n].type == SELABEL_OPT_DIGEST &&
opts[n].value == (char *)1) {
digest = calloc(1, sizeof(*digest));
Expand Down Expand Up @@ -112,9 +113,11 @@ static void selabel_digest_fini(struct selabel_digest *ptr)
static inline int selabel_is_validate_set(const struct selinux_opt *opts,
unsigned n)
{
while (n--)
while (n) {
n--;
if (opts[n].type == SELABEL_OPT_VALIDATE)
return !!opts[n].value;
}

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion libselinux/src/label_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,8 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
int status = -1, baseonly = 0;

/* Process arguments */
while (n--) {
while (n) {
n--;
switch(opts[n].type) {
case SELABEL_OPT_PATH:
path = opts[n].value;
Expand Down
7 changes: 7 additions & 0 deletions libselinux/src/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ typedef union
//
// Hash a single 512-bit block. This is the core of the algorithm
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(__clang__) && defined(__clang_major__) && (__clang_major__ >= 4)
#if (__clang_major__ >= 12)
__attribute__((no_sanitize("unsigned-integer-overflow", "unsigned-shift-base")))
#else
__attribute__((no_sanitize("unsigned-integer-overflow")))
#endif
#endif
static
void
TransformFunction
Expand Down
2 changes: 1 addition & 1 deletion libsemanage/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $(LIBA): $(OBJS)
$(RANLIB) $@

$(LIBSO): $(LOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -Wl,-soname,$(LIBSO),--version-script=libsemanage.map
ln -sf $@ $(TARGET)

$(LIBPC): $(LIBPC).in ../VERSION
Expand Down
2 changes: 1 addition & 1 deletion libsepol/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ifeq (yes,$(shell printf '${H}define _GNU_SOURCE\n${H}include <stdlib.h>\nint ma
override CFLAGS += -DHAVE_REALLOCARRAY
endif

LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=$(LIBMAP),-z,defs
LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=$(LIBMAP)

LN=ln
OS := $(shell uname)
Expand Down
2 changes: 1 addition & 1 deletion policycoreutils/setfiles/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int process_glob(char *name, struct restore_opts *opts, size_t nthreads,
return errors;

for (i = 0; i < globbuf.gl_pathc; i++) {
len = strlen(globbuf.gl_pathv[i]) - 2;
len = (int)strlen(globbuf.gl_pathv[i]) - 2;
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len--], "/.") == 0)
continue;
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
Expand Down

0 comments on commit c33c9a5

Please sign in to comment.