Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
1ba4ae89
Unverified
Commit
1ba4ae89
authored
Nov 06, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terminal: prevent returning invalid pointer
Closes:
https://github.com/lxc/lxd/issues/6408
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
26ed61e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
22 deletions
+13
-22
terminal.c
src/lxc/terminal.c
+13
-22
No files found.
src/lxc/terminal.c
View file @
1ba4ae89
...
...
@@ -115,8 +115,8 @@ int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
struct
lxc_terminal_state
*
lxc_terminal_signal_init
(
int
srcfd
,
int
dstfd
)
{
__do_close_prot_errno
int
signal_fd
=
-
EBADF
;
__do_free
struct
lxc_terminal_state
*
ts
=
NULL
;
bool
istty
=
false
;
int
ret
;
sigset_t
mask
;
...
...
@@ -132,49 +132,40 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
ret
=
sigemptyset
(
&
mask
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to initialize an empty signal set"
);
goto
on_error
;
return
NULL
;
}
istty
=
(
isatty
(
srcfd
)
==
1
);
if
(
!
istty
)
{
INFO
(
"fd %d does not refer to a tty device"
,
srcfd
);
}
else
{
if
(
isatty
(
srcfd
))
{
ret
=
sigaddset
(
&
mask
,
SIGWINCH
);
if
(
ret
<
0
)
SYSNOTICE
(
"Failed to add SIGWINCH to signal set"
);
}
else
{
INFO
(
"fd %d does not refer to a tty device"
,
srcfd
);
}
/* Exit the mainloop cleanly on SIGTERM. */
ret
=
sigaddset
(
&
mask
,
SIGTERM
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to add SIGWINCH to signal set"
);
goto
on_error
;
return
NULL
;
}
ret
=
pthread_sigmask
(
SIG_BLOCK
,
&
mask
,
&
ts
->
oldmask
);
if
(
ret
<
0
)
{
WARN
(
"Failed to block signals"
);
goto
on_error
;
return
NULL
;
}
ts
->
sig
fd
=
signalfd
(
-
1
,
&
mask
,
SFD_CLOEXEC
);
if
(
ts
->
sig
fd
<
0
)
{
signal_
fd
=
signalfd
(
-
1
,
&
mask
,
SFD_CLOEXEC
);
if
(
signal_
fd
<
0
)
{
WARN
(
"Failed to create signal fd"
);
(
void
)
pthread_sigmask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
);
goto
on_error
;
}
DEBUG
(
"Created signal fd %d"
,
ts
->
sigfd
);
return
ts
;
on_error:
ERROR
(
"Failed to create signal fd"
);
if
(
ts
->
sigfd
>=
0
)
{
close
(
ts
->
sigfd
);
ts
->
sigfd
=
-
1
;
return
NULL
;
}
ts
->
sigfd
=
move_fd
(
signal_fd
);
TRACE
(
"Created signal fd %d"
,
ts
->
sigfd
);
return
NULL
;
return
move_ptr
(
ts
)
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment