From 6b35ae81a38573dcc42a944ebd8c2e6317cf5ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Mon, 8 Nov 2021 17:44:18 +0300 Subject: slicecpy: fix buffer overflow on sections shorter than 3 chars. --- Makefile | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a21748b..6576a87 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,39 @@ CC?=gcc -RM:=rm -rf -SRC_DIR:=src -OBJ_DIR:=obj +CFLAGS:=-std=c99 -O0 -g -Wall -DDEBUG + INC_DIRS=$(addprefix -iquote,include) -PARCINI_SOURCES:=$(wildcard $(SRC_DIR)/*.c) -PARCINI_OBJECTS:=$(PARCINI_SOURCES:%.c=$(OBJ_DIR)/%.o) -BUILD_DIR:=build +BUILDIR:=build +OBJDIR:=$(BUILDIR)/obj + +PARCINI_SRCS:=$(wildcard src/*.c) +PARCINI_OBJS:=$(PARCINI_SRCS:%.c=$(OBJDIR)/%.o) -test: CFLAGS := -std=c99 -O0 -g -Wall -DDEBUG -test: $(BUILD_DIR) tests/parcini +ifdef ASAN +CFLAGS+= -fsanitize=address -fno-omit-frame-pointer +endif -tests/%: $(OBJ_DIR)/src/tests/%.o $(PARCINI_OBJECTS) - $(CC) $(LDFLAGS) -o $(BUILD_DIR)/$@ $^ - $(BUILD_DIR)/$@ +test: +test: $(BUILDIR) tests/parcini + +tests/%: $(OBJDIR)/src/tests/%.o $(PARCINI_OBJS) + mkdir -p $(BUILDIR)/$(@D) + $(CC) $(CFLAGS) $(LDFLAGS) -o $(BUILDIR)/$@ $^ + $(BUILDIR)/$@ example: CFLAGS := -std=c99 -O2 -Wall -example: $(OBJ_DIR)/example/example.o $(PARCINI_OBJECTS) - $(CC) $(LDFLAGS) -o $(BUILD_DIR)/example/$@ $^ +example: $(OBJDIR)/example/example.o $(PARCINI_OBJS) + mkdir -p $(@D) + $(CC) $(LDFLAGS) -o $(BUILDIR)/example/$@ $^ -$(OBJ_DIR)/%.o: %.c +$(OBJDIR)/%.o: %.c + mkdir -p $(@D) $(CC) -c $(CFLAGS) $(INC_DIRS) -o $@ $< -$(BUILD_DIR): - mkdir -p $(BUILD_DIR)/tests - mkdir -p $(BUILD_DIR)/example - mkdir -p $(OBJ_DIR)/src/tests - mkdir -p $(OBJ_DIR)/example - clean: - $(RM) $(OBJ_DIR) - $(RM) $(BUILD_DIR) + rm -r $(BUILDIR) .PHONY: clean test -.PRECIOUS: $(OBJ_DIR)/tests/%.o $(OBJ_DIR)/%.o +.PRECIOUS: $(OBJDIR)/tests/%.o $(OBJDIR)/%.o -- cgit v1.2.3