> On 29 Sep 2017, at 11:03 am, Ondrej Sury via RT wrote: > > Thank you for doing this, it mostly look good. > > Also forgive me if my comments doesn't make sense, as I don't have a deep understanding of BIND 9 source code, so you'll have to be patient with me. > > A general comment - you never change the snprintf return value, so the assumption is that the resulting string always fits from the previous usage of sprintf (otherwise it would smash the stack), but is the assumption always true? Especially in the places where the correct output matters (like totext_* functions). The code was already correct. The problem is that OS developers have made the linker so noisy it is hard to see real issues for false positives. > One little nitpick - in lib/dns/gssapictx.c > > Could you change this: > > + size = strlen(gssapi_keytab) + 13; > + kt = malloc(size); > > to: > > + size_t size = strlen(gssapi_keytab) + sizeof("KRB5_KTNAME=") + 1; > + char *kt = malloc(size); I dislike initialisations with declarations that depend on each other. Additionally the second is not safe from “sort(declaration block)”. > > -- > > I am curious about changes in lib/dns/rdata/generic/loc_29.c > > While I am generally in favour of using curly braces even around single statements (as I do believe it makes the code more readable and a tad bit safer for mistakes), this is not really consistent with the rest of the coding style found in the BIND 9. > > -- > > Again a nitpick (if we are going to go toward C11), in lib/isc/inet_ntop.c, could you please create the variable close to the usage, e.g. change: > > + int n; > + > + n = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); > > to single line: > > + int n = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]) We still only require C99 and even there declarations need to be at the start of a block as the Windows compilers blow up. > -- > > dtto in lib/isc/log.c and why is size unsigned int and not size_t? changed. > -- > > In lib/isccfg/parser.c, it seems to me that this change could be rewritten as: > > - message[sizeof(message) - sizeof(ELIPSIS)] = 0; > - strlcat(message, ELIPSIS, sizeof(message)); > + strncpy(message + sizeof(message) - sizeof(ELIPSIS), ELIPSIS, sizeof(ELIPSIS)); > > strlcat() can be used, but the result should be same. It would save one iteration through 2048 sized buffer every time the log message overflows strncpy() also flags with compiler/linker warnings as it is much more often misused than even strcpy. The original strlcat usage meets the spirit of the reasons for strlcat by clearly ensuring that message isn’t overflowed and we rarely overflow. > -- > Ticket History: https://bugs.isc.org/Ticket/Display.html?id=46132 -- Mark Andrews, ISC 1 Seymour St., Dundas Valley, NSW 2117, Australia PHONE: +61 2 9871 4742 INTERNET: marka@isc.org