Re: [PATCH v2 21/22] mingw32: add uname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014-11-09 09.36, Duy Nguyen wrote:
> On Sun, Nov 9, 2014 at 10:32 AM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
>> On Sat, Nov 8, 2014 at 4:39 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
>>> ---
>>> diff --git a/compat/mingw.c b/compat/mingw.c
>>> index c5c37e5..b817678 100644
>>> --- a/compat/mingw.c
>>> +++ b/compat/mingw.c
>>> @@ -2128,3 +2128,14 @@ void mingw_startup()
>>>         /* initialize Unicode console */
>>>         winansi_init();
>>>  }
>>> +
>>> +int uname(struct utsname *buf)
>>> +{
>>> +       DWORD v = GetVersion();
>>> +       memset(buf, 0, sizeof(*buf));
>>> +       sprintf(buf->sysname, "Windows");
>>
>> strcpy() maybe?
> 
> It was originally strcpy, then I wanted to get fancy and show Win3.1,
> Win95... but it got complicated (couldn't just do it based on the last
> bit of 'v'). Will revert.
> 
Why not use strlcpy() ?
(This feels little like an overkill, but on the other hand it is safe to use regardless
how long the buf is, and it is a good example how to avoid "overrunning" code)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]