From 87a31ba0390f7c4c7af34544a7baf5a975e0b61d Mon Sep 17 00:00:00 2001 From: Mithil Poojary Date: Sat, 3 Oct 2020 03:21:38 +0530 Subject: [PATCH] Avoid passing null pointer to strncpy --- src/mboxscan.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mboxscan.cc b/src/mboxscan.cc index 26f2f11b..d90cdce0 100644 --- a/src/mboxscan.cc +++ b/src/mboxscan.cc @@ -131,7 +131,9 @@ static void mbox_scan(char *args, char *output, size_t max_len) { tmp = strtok(nullptr, " "); if (tmp != nullptr) { start = tmp; } } - strncpy(mbox_mail_spool, start, DEFAULT_TEXT_BUFFER_SIZE); + if (start != nullptr) { + strncpy(mbox_mail_spool, start, DEFAULT_TEXT_BUFFER_SIZE); + } free(copy_args); } if (strlen(mbox_mail_spool) < 1) {