Skip to content

Commit 9f7b23c

Browse files
committed
Fix oss-fuzz 67175, 67180, 67191
Embedded 0 characters in a file would prevent the loading of that file. This could not happen apart from corruption of the file, or by deliberate manipulation by the admin. Minimal impact.
1 parent 2762a87 commit 9f7b23c

File tree

9 files changed

+20
-8
lines changed

9 files changed

+20
-8
lines changed

apps/mosquitto_passwd/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ OBJS_EXTERNAL= \
1717
memory_mosq.o \
1818
memory_public.o \
1919
misc_mosq.o \
20-
password_mosq.o
20+
password_mosq.o \
21+
utf8_mosq.o
2122

2223

2324
ifeq ($(WITH_TLS),yes)
@@ -54,6 +55,9 @@ misc_mosq.o : ${R}/common/misc_mosq.c ${R}/common/misc_mosq.h
5455
password_mosq.o : ${R}/common/password_mosq.c ${R}/common/password_mosq.h
5556
${CROSS_COMPILE}${CC} ${LOCAL_CPPFLAGS} $(LOCAL_CFLAGS) -c $< -o $@
5657

58+
utf8_mosq.o : ${R}/common/utf8_mosq.c
59+
${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@
60+
5761
install : all
5862
ifeq ($(WITH_TLS),yes)
5963
$(INSTALL) -d "${DESTDIR}$(prefix)/bin"

common/misc_mosq.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ char *fgets_extending(char **buf, int *buflen, FILE *stream)
284284
if(endchar == '\n'){
285285
return rc;
286286
}
287+
if((int)(len+1) < *buflen){
288+
/* Embedded nulls, invalid string */
289+
return NULL;
290+
}
291+
287292
/* No EOL char found, so extend buffer */
288293
offset = (*buflen)-1;
289294
*buflen += 1000;
File renamed without changes.

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ set(C_SRC
5050
thread_mosq.c
5151
../common/time_mosq.c ../common/time_mosq.h
5252
tls_mosq.c
53-
utf8_mosq.c
53+
../common/utf8_mosq.c
5454
util_mosq.c util_topic.c util_mosq.h
5555
will_mosq.c will_mosq.h)
5656

lib/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ OBJS= \
8181
strings_mosq.o \
8282
thread_mosq.o \
8383
tls_mosq.o \
84-
utf8_mosq.o \
8584
util_mosq.o \
8685
util_topic.o \
8786
will_mosq.o
@@ -90,7 +89,8 @@ OBJS_EXTERNAL= \
9089
base64_mosq.o \
9190
misc_mosq.o \
9291
password_mosq.o \
93-
time_mosq.o
92+
time_mosq.o \
93+
utf8_mosq.o
9494

9595
ifeq ($(WITH_WEBSOCKETS),yes)
9696
OBJS_EXTERNAL+=${R}/deps/picohttpparser/picohttpparser.o
@@ -160,5 +160,8 @@ password_mosq.o : ${R}/common/password_mosq.c net_mosq.h
160160
time_mosq.o : ${R}/common/time_mosq.c ${R}/common/time_mosq.h
161161
${CROSS_COMPILE}$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@
162162

163+
utf8_mosq.o : ${R}/common/utf8_mosq.c
164+
${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@
165+
163166
${R}/deps/picohttpparser/picohttpparser.o : ${R}/deps/picohttpparser/picohttpparser.c
164167
${CROSS_COMPILE}$(CC) $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ set (MOSQ_SRCS
7777
../lib/tls_mosq.c
7878
topic_tok.c
7979
../lib/util_mosq.c ../lib/util_topic.c ../lib/util_mosq.h
80-
../lib/utf8_mosq.c
80+
../common/utf8_mosq.c
8181
websockets.c
8282
will_delay.c
8383
../lib/will_mosq.c ../lib/will_mosq.h

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ util_mosq.o : ${R}/lib/util_mosq.c ${R}/lib/util_mosq.h
247247
util_topic.o : ${R}/lib/util_topic.c ${R}/lib/util_mosq.h
248248
${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@
249249

250-
utf8_mosq.o : ${R}/lib/utf8_mosq.c
250+
utf8_mosq.o : ${R}/common/utf8_mosq.c
251251
${CROSS_COMPILE}${CC} $(LOCAL_CPPFLAGS) $(LOCAL_CFLAGS) -c $< -o $@
252252

253253
will_mosq.o : ${R}/lib/will_mosq.c ${R}/lib/will_mosq.h

test/unit/broker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ ${R}/src/util_mosq.o : ${R}/lib/util_mosq.c
177177
${R}/src/util_topic.o : ${R}/lib/util_topic.c
178178
$(MAKE) -C ${R}/src/ util_topic.o
179179

180-
${R}/src/utf8_mosq.o : ${R}/lib/utf8_mosq.c
180+
${R}/src/utf8_mosq.o : ${R}/common/utf8_mosq.c
181181
$(MAKE) -C ${R}/src/ utf8_mosq.o
182182

183183
build : bridge_topic_test keepalive_test persist_read_test persist_write_test subs_test

test/unit/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ${R}/lib/util_mosq.o : ${R}/lib/util_mosq.c
7676
${R}/lib/util_topic.o : ${R}/lib/util_topic.c
7777
$(MAKE) -C ${R}/lib/ util_topic.o
7878

79-
${R}/lib/utf8_mosq.o : ${R}/lib/utf8_mosq.c
79+
${R}/lib/utf8_mosq.o : ${R}/common/utf8_mosq.c
8080
$(MAKE) -C ${R}/lib/ utf8_mosq.o
8181

8282
build : lib_test

0 commit comments

Comments
 (0)