diff options
| -rw-r--r-- | Makefile | 13 | ||||
| -rw-r--r-- | src/c_mpdview.c | 21 | 
2 files changed, 18 insertions, 16 deletions
| @@ -11,7 +11,7 @@  # ========================  #  # mpdview: Makefile -# Sun, 03 Jul 2022 15:15:01 +0200 +# Tue, 12 Jul 2022 20:25:26 +0200  # Joe  #  # BSD Makefile @@ -20,7 +20,6 @@ default: all  SRCS_DIR	:= src  MAN_DIR		:= man -# OBJS_DIR	:= obj  PREFIX		?= /usr/local  DESTDIR		:=  MAKEOBJDIR	:= ./ @@ -47,7 +46,11 @@ CFLAGS		+= -Werror  CFLAGS		+= -pedantic  CFLAGS		+= -isystem/usr/local/include  CFLAGS		+= -glldb -# CFLAGS		+= -march=native -O2 -pipe +CFLAGS		+= -O0 +# CFLAGS		+= -march=ivybridge +# CFLAGS		+= -O3 +CFLAGS		+= -pipe +# CFLAGS		+= -fsanitize=address  LDFLAGS		:= -L/usr/local/lib  LDFLAGS		+= -lmpdclient @@ -68,7 +71,7 @@ INSTALL		:= install  ${NAME}: ${OBJS}  	${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC} ${LDFLAGS}  -all: ${OBJS_DIR} ${NAME} +all: ${OBJS} ${NAME}  clean:  	${RM} ${OBJS} ${NAME} vgcore* @@ -85,7 +88,7 @@ uninstall:  	${RM} ${PREFIX}/man/man1/${NAME}.1.gz  	${RM} ${PREFIX}/bin/${NAME} -.PHONY: all clean install +.PHONY: all asan clean install  # Files prefixes index  # -------------------- diff --git a/src/c_mpdview.c b/src/c_mpdview.c index 26af420..46e11ed 100644 --- a/src/c_mpdview.c +++ b/src/c_mpdview.c @@ -39,13 +39,14 @@   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   *   * mpdview: src/c_mpdview.c - * Sun, 03 Jul 2022 16:06:29 +0200 + * Tue, 12 Jul 2022 21:36:26 +0200   * Joe   *   * This is the entrypoint of the program.   */  #include <sys/param.h> +#include <sys/syslimits.h>  #include <stdlib.h>  #include <stdio.h> @@ -70,6 +71,9 @@ c_create_view(void)  	struct mpdview_s* view;  	view = (struct mpdview_s*)malloc(sizeof(struct mpdview_s)); +	if (view == NULL) { +		return (NULL); +	}  	view->conn = NULL;  	view->status = NULL;  	view->song = NULL; @@ -159,17 +163,12 @@ c_get_current_dir(struct mpdview_s* v)  {  	ptr_t ptr; -	snprintf( -		v->current_dir, -		PATH_MAX, -		"%s/%s", -		v->music_dir, -		mpd_song_get_uri(v->song) -		); +	strlcpy(v->current_dir, v->music_dir, PATH_MAX); +	v->current_dir[strlen(v->current_dir) + 1] = 0x00; +	v->current_dir[strlen(v->current_dir)] = '/'; +	strlcat(v->current_dir, mpd_song_get_uri(v->song), PATH_MAX);  	ptr = v->current_dir; -	while (*ptr != 0x00) { -		ptr++; -	} +	ptr += strlen(v->current_dir);  	while (*ptr != '/' && ptr > v->music_dir) {  		ptr--;  	} | 
