The libc standard does not define the behavior 
when passing a NULL value as a pathname value to an open() call, 
so a NULL check for the fn pointer has been added.

Signed-off-by: Maks Mishin <[email protected]>
---
 editors/vi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/editors/vi.c b/editors/vi.c
index 34932f60c..284630ef4 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1990,6 +1990,9 @@ static int file_insert(const char *fn, char *p, int 
initial)
        if (p > end)
                p = end;
 
+       if (fn == NULL)
+               return cnt;
+
        fd = open(fn, O_RDONLY);
        if (fd < 0) {
                if (!initial)
-- 
2.43.0

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to