提交 3f6dc304 编写于 作者: M Marc André Tanner 提交者: Rich Felker

fix out of bounds write for zero length buffer in gethostname

上级 0b80a7b0
......@@ -8,6 +8,6 @@ int gethostname(char *name, size_t len)
if (uname(&uts)) return -1;
if (len > sizeof uts.nodename) len = sizeof uts.nodename;
for (i=0; i<len && (name[i] = uts.nodename[i]); i++);
if (i==len) name[i-1] = 0;
if (i && i==len) name[i-1] = 0;
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册