buglwIP - A Lightweight TCP/IP stack - Bugs: bug #49124, MDNS should not use snprintf()

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #49124: MDNS should not use snprintf()

Submitted by:  Daniel Elstner <danielk>
Submitted on:  Mon 19 Sep 2016 02:07:28 AM UTC  
 
Category: DNSSeverity: 3 - Normal
Item Group: Compiler WarningStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Mon 19 Sep 2016 10:24:21 AM UTC, comment #3:

Thank you for your patch. I don't think refactoring is needed here, to create a generically usable "itoa" you need to deal with buffer sizes which would add (too much?) overhead.

Dirk Ziegelmeier <dziegel>
Project Member
Mon 19 Sep 2016 09:27:59 AM UTC, comment #2:

No, itoa() is apparently non-standard.

I've had a look at ip4addr_ntoa_r() for reference, which rolls its own conversion code. In the attached patch I've now done something similar for mDNS. Not sure whether it might be worth factoring out into a utility function.

(file #38548)

Daniel Elstner <danielk>
Mon 19 Sep 2016 06:39:59 AM UTC, comment #1:

Can you try whether this works?

[...]
char buf[4];
size_t len;
itoa(ptr[i], buf, 10);
len = strnlen(buf, sizeof(buf));
res = mdns_domain_add_label(domain, buf, (u8_t)len);
[...]

Dirk Ziegelmeier <dziegel>
Project Member
Mon 19 Sep 2016 02:07:28 AM UTC, original submission:

The MDNS code makes use of snprintf() without including stdio.h:

src/apps/mdns/mdns.c:508: error: implicit declaration of function 'snprintf'

However, rather than adding the #include, I would prefer if MDNS did not use snprintf() at all, or at least not directly. Many embedded applications avoid using the C library's printf() altogether due to code size and stack usage restrictions, and lwIP should not drag it in.

Daniel Elstner <danielk>

 

Attached Files
file #38548:  0001-Fix-bug-49124-mDNS-should-not-use-snprintf.patch added by danielk (1KiB - text/x-patch - Fix without snprintf() or itoa())

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dziegel (Posted a comment)
  • -unavailable- added by danielk (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 19 Sep 2016 10:24:21 AM UTCdziegelStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Mon 19 Sep 2016 09:27:58 AM UTCdanielkAttached File-=>Added 0001-Fix-bug-49124-mDNS-should-not-use-snprintf.patch, #38548

    Back to the top


    Powered by Savane 3.1-cleanup1