[CLOSED] SEGGER_RTT_vprintf / SEGGER_RTT_printf string format NULL check

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [CLOSED] SEGGER_RTT_vprintf / SEGGER_RTT_printf string format NULL check

    Hi Segger Team,

    we're having software that passes printf format strings with %s in the format string, but the corresponding char * is NULL in same cases.

    As it is cumbersome to check the variadic arguments (va_args) values before passing them into SEGGER_RTT_vprintf we do patch the Segger RTT sources with an additional check right now.



    We also created a patch file: null_string_va_arg.zip

    It would be nice, if this patch could get part of the official RTT release.

    Thanks

    Best regards
    Philipp Häfele
  • Hi mwb1100,

    wasn't aware of that behavior.

    Patch would then look something like that:

    Source Code: SEGGER_RTT_printf.c

    1. if(s == NULL) {
    2. _StoreChar(&BufferDesc, '(');
    3. _StoreChar(&BufferDesc, 'n');
    4. _StoreChar(&BufferDesc, 'u');
    5. _StoreChar(&BufferDesc, 'l');
    6. _StoreChar(&BufferDesc, 'l');
    7. _StoreChar(&BufferDesc, ')');
    8. break;
    9. }

    which is also totally ok :thumbup:

    The post was edited 1 time, last by ifmPhilipp: characters need to be in single quotes instead of double onces " => ' ().

  • Hi Philipp,
    Sorry for the delay in response.

    We agree that a crash should be avoided here.
    We will add a "NULL" (or similar) return message at some point in the future.

    Please note that we are currently fully booked with projects,
    so we cannot provide a timeline for when this will be available.

    We will close this thread now.

    Best regards
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi everyone,
    this was officially added with the release of J-Link Software Version V7.92i.
    Excerpt from the release notes:

    Source Code

    1. SEGGER_RTT_vprintf(): %s handling: In case string is NULL-pointer, function will now write "(NULL)" instead of doing a NULL-pointer access.

    BR
    Fabian Federschmidt
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.