Skip to content

Commit

Permalink
secure ioctl
Browse files Browse the repository at this point in the history
  • Loading branch information
rclanget committed Dec 16, 2016
1 parent 3f838ea commit 15f8a14
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions srcs/termcaps_readline/termcap_winsz.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: zipo <zipo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/31 19:36:57 by zipo #+# #+# */
/* Updated: 2016/11/14 16:12:09 by ulefebvr ### ########.fr */
/* Updated: 2016/12/14 20:42:27 by rclanget ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,14 +19,16 @@ int termcap_winsz_x(void)
{
struct winsize w;

ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
return (w.ws_col);
if (-1 != ioctl(STDOUT_FILENO, TIOCGWINSZ, &w))
return (w.ws_col);
return (0);
}

int termcap_winsz_y(void)
{
struct winsize w;

ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
return (w.ws_row);
if (-1 != ioctl(STDOUT_FILENO, TIOCGWINSZ, &w))
return (w.ws_row);
return (0);
}

0 comments on commit 15f8a14

Please sign in to comment.