mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Prevent freeing a possible invalid pointer from journald
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
(cherry picked from commit 81630df854
)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
91d33f250b
commit
52a7b8350a
1 changed files with 5 additions and 3 deletions
|
@ -237,7 +237,10 @@ drain:
|
|||
|
||||
// free(NULL) is safe
|
||||
C.free(unsafe.Pointer(oldCursor))
|
||||
C.sd_journal_get_cursor(j, &cursor)
|
||||
if C.sd_journal_get_cursor(j, &cursor) != 0 {
|
||||
// ensure that we won't be freeing an address that's invalid
|
||||
cursor = nil
|
||||
}
|
||||
return cursor
|
||||
}
|
||||
|
||||
|
@ -264,7 +267,6 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
|
|||
s.readers.mu.Lock()
|
||||
delete(s.readers.readers, logWatcher)
|
||||
s.readers.mu.Unlock()
|
||||
C.sd_journal_close(j)
|
||||
close(logWatcher.Msg)
|
||||
}()
|
||||
// Wait until we're told to stop.
|
||||
|
@ -298,9 +300,9 @@ func (s *journald) readLogs(logWatcher *logger.LogWatcher, config logger.ReadCon
|
|||
following := false
|
||||
defer func(pfollowing *bool) {
|
||||
if !*pfollowing {
|
||||
C.sd_journal_close(j)
|
||||
close(logWatcher.Msg)
|
||||
}
|
||||
C.sd_journal_close(j)
|
||||
}(&following)
|
||||
// Remove limits on the size of data items that we'll retrieve.
|
||||
rc = C.sd_journal_set_data_threshold(j, C.size_t(0))
|
||||
|
|
Loading…
Add table
Reference in a new issue