Some patches to compile with gcc-next

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Tue Nov 29 22:13:47 UTC 2016


On 08/11/16 06:18, Jeremy Allison wrote:
> On Wed, Nov 02, 2016 at 05:03:42PM -0700, Jeremy Allison wrote:
>> On Thu, Nov 03, 2016 at 09:52:07AM +1300, Douglas Bagnall wrote:
>>>
>>> The real bug is in smbclient, which I think I have fixed. There it was
>>> trying to overwrite a string like "stdin-<pid>" onto the considerably
>>> shorter string "-", but the snprintf limit was actually set to
>>> sizeof(char *) - 1.
>>>
>>> ../source4/client/client.c: In function ‘cmd_print’:
>>> ../source4/client/client.c:1545:45: error: output truncated before the last format character [-Werror=format-length=]
>>>    slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid());
>>>                                      ~~~~~~~~^
>>> In file included from ../source4/include/includes.h:23:0,
>>>                  from ../source4/client/client.c:32:
>>> ../lib/replace/../replace/replace.h:510:18: note: format output between 8 and 18 bytes into a destination of size 7
>>>  #define slprintf snprintf
>>> ../source4/client/client.c:1545:3: note: in expansion of macro ‘slprintf’
>>>    slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid());
>>>    ^~~~~~~~
>>
>> Yeah, that's in the smbclient4 which isn't used as a production
>> tool. Good catch though.
>>
>> I'll take a look at PATCH 4/4 tomorrow and review !
> 
> Douglas - slprintf has been deprecated (as you see above
> with the #define slprintf snprintf).
> 
> Can you rewrite patch 4/4 to use snprintf instead with
> the correct size_t lengths ? Let me know if you don't
> have time and I'll take a look at doing it.

Ah yes. It seems I poorly estimated my available time.

This version uses talloc_asprintf() so the size calculations are all
hidden away and hopefully correct.


Douglas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-smbclient-fix-string-formatting-in-print-command.patch
Type: text/x-diff
Size: 1629 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161130/04f3f692/0001-smbclient-fix-string-formatting-in-print-command.diff>


More information about the samba-technical mailing list