mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
correctly use HOST_NAME_MAX.
Some notes: POSIX HOST_NAME_MAX doesn't include the NUL. POSIX LOGIN_NAME_MAX and TTY_NAME_MAX do include the NUL. BSD MAXHOSTNAMELEN includes the NUL. Actually, most of the historical BSD MAX* defines did include the NUL, except for the historical mistake of utmp fields without NULs in the string, which directly led to strncpy.. just showing how error prone this kind of accounting is. CSRG did right. Somehow POSIX missed the memo on the concepts of carefulness and consistancy, and we are still paying the price when people trip over this. Of course, glibc is even more amazing (that is a hint to blackhats) ok guenther
This commit is contained in:
parent
aae2b7aa89
commit
8a8e2eb04a
2
format.c
2
format.c
@ -133,7 +133,7 @@ struct format_tree *
|
||||
format_create(void)
|
||||
{
|
||||
struct format_tree *ft;
|
||||
char host[MAXHOSTNAMELEN], *ptr;
|
||||
char host[HOST_NAME_MAX+1], *ptr;
|
||||
|
||||
ft = xcalloc(1, sizeof *ft);
|
||||
RB_INIT(&ft->tree);
|
||||
|
4
screen.c
4
screen.c
@ -31,11 +31,11 @@ void screen_resize_y(struct screen *, u_int);
|
||||
void
|
||||
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
|
||||
{
|
||||
char host[HOST_NAME_MAX];
|
||||
char host[HOST_NAME_MAX+1];
|
||||
|
||||
s->grid = grid_create(sx, sy, hlimit);
|
||||
|
||||
if (gethostname(host, HOST_NAME_MAX) == 0)
|
||||
if (gethostname(host, sizeof(host)) == 0)
|
||||
s->title = xstrdup(host);
|
||||
else
|
||||
s->title = xstrdup("");
|
||||
|
Loading…
Reference in New Issue
Block a user