Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccnl_addr2ascii returns NULL pointer #232

Open
mfrey opened this issue May 4, 2018 · 3 comments
Open

ccnl_addr2ascii returns NULL pointer #232

mfrey opened this issue May 4, 2018 · 3 comments
Labels

Comments

@mfrey
Copy link
Collaborator

mfrey commented May 4, 2018

RIOT maps the various logging calls of ccn-lite to printf. Below is a snippet from ccnl-riot-logging.h (in ccn-lite).

 55 #define DEBUGMSG(LVL, ...) do {       \
 56         if ((LVL)>debug_level) break;   \
 57         LOG(LVL, __VA_ARGS__);   \
 58     } while (0)

and in RIOT LOG points to log_write points to printf (see core/include/log.h in RIOT)

 #define log_write(level, ...) printf(__VA_ARGS__)

The function ccnl_addr2ascii ccn-lite returns NULL if no valid parameter was passed to it. If one embeds a call to ccnl_addr2ascii in a logging macro call and passes NULL as a argument, the function returns NULL. Subsequently, the NULL which is passed to a %s leads to undefined behaviour (most likely a crash).

This can for example observed in ccnl_fwd.c, e.g.

236     DEBUGMSG_CFWD(INFO, "  incoming interest=<%s>%s nonce=%"PRIi32" from=%s\n",
237                   ccnl_prefix_to_str((*pkt)->pfx,s,CCNL_MAX_PREFIX_SIZE),
238                   ccnl_suite2str((*pkt)->suite), nonce,
239                   ccnl_addr2ascii(from ? &from->peer : NULL));

This issue is related to #231

@mfrey mfrey added the bug label May 4, 2018
@mfrey
Copy link
Collaborator Author

mfrey commented May 4, 2018

This issue probably also applies to other logging mappings in ccn-lite.

@mfrey
Copy link
Collaborator Author

mfrey commented May 8, 2018

I think we should stick with "NULL" as a return value and simply remove all parts of the code which pass clearly "NULL" to the function. Any thoughts?

@mfrey mfrey added wontfix and removed bug labels May 9, 2018
@mfrey
Copy link
Collaborator Author

mfrey commented May 9, 2018

I've removed the "bug" label. I think that the function is simply applied in a wrongful way. A developer should check if the function returns NULL before simply passing it to a format string which expects a string such as "%s".

@blacksheeep any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant