Giter Club home page Giter Club logo

Comments (3)

MeindertKempe avatar MeindertKempe commented on May 25, 2024

That appears to be a message from ubsan, at the indicated line browser/complete.c:139:5 there is a call to memcpy, the first argument is allocated the line before using mutt_mem_realloc. With the buffer being empty the size passed to mutt_mem_realloc is 0, which results in memcpy using a NULL pointer as the destination buffer, since the size passed to memcpy is also 0 I don't believe particularly disastrous is likely to happen, but it is undefined behaviour to pass a NULL pointer to memcpy.

I'm not entirely certain how this complete function is supposed to function, but I believe it would be relatively simple to add a simple check for the case of 0 length.

from neomutt.

flatcap avatar flatcap commented on May 25, 2024

Thanks for the bug report; I haven't had a chance to investigate yet.

As you've already noted, a simple check would stop the problem.
I'll certainly add something like that to the code before the next release.

However...

What I'd love to know is why we're getting a NULL there.

If someone has a bit of time to dig into the code, it'd really be appreciated.
Feel free to ask lots of questions here, or on IRC: #neomutt on irc.libera.chat (web client)

Thanks!

from neomutt.

roccoblues avatar roccoblues commented on May 25, 2024

I can't seem reproduce this.

With ubsan enabled I actually get a different error on every completion, not just empty. Maybe because I'm on macOS.

 editor/functions.c:187:12: runtime error: call to function complete_file_simple through pointer to incorrect function type 'enum FunctionRetval (*)(struct EnterWindowData *, int)'
             complete.c:114: note: complete_file_simple defined here
                                                                    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior editor/functions.c:187:12

Which I can fix with:

diff --git a/browser/complete.c b/browser/complete.c
index f6dca66e1..673668a44 100644
--- a/browser/complete.c
+++ b/browser/complete.c
@@ -110,7 +110,7 @@ int complete_file_mbox(struct EnterWindowData *wdata, int op)
 /**
  * complete_file_simple - Complete a filename - Implements ::complete_function_t - @ingroup complete_api
  */
-int complete_file_simple(struct EnterWindowData *wdata, int op)
+enum FunctionRetval complete_file_simple(struct EnterWindowData *wdata, int op)
 {
   if (!wdata || ((op != OP_EDITOR_COMPLETE) && (op != OP_EDITOR_COMPLETE_QUERY)))
     return FR_NO_ACTION;

from neomutt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.