Merge pull request #31231 from mlaventure/fix-journald-invalid-free
Prevent freeing a possible invalid pointer from journald
This commit is contained in:
commit
f67eb69fe3
|
@ -237,7 +237,10 @@ drain:
|
||||||
|
|
||||||
// free(NULL) is safe
|
// free(NULL) is safe
|
||||||
C.free(unsafe.Pointer(oldCursor))
|
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
|
return cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +275,6 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
|
||||||
s.readers.mu.Lock()
|
s.readers.mu.Lock()
|
||||||
delete(s.readers.readers, logWatcher)
|
delete(s.readers.readers, logWatcher)
|
||||||
s.readers.mu.Unlock()
|
s.readers.mu.Unlock()
|
||||||
C.sd_journal_close(j)
|
|
||||||
close(logWatcher.Msg)
|
close(logWatcher.Msg)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -307,9 +309,9 @@ func (s *journald) readLogs(logWatcher *logger.LogWatcher, config logger.ReadCon
|
||||||
following := false
|
following := false
|
||||||
defer func(pfollowing *bool) {
|
defer func(pfollowing *bool) {
|
||||||
if !*pfollowing {
|
if !*pfollowing {
|
||||||
C.sd_journal_close(j)
|
|
||||||
close(logWatcher.Msg)
|
close(logWatcher.Msg)
|
||||||
}
|
}
|
||||||
|
C.sd_journal_close(j)
|
||||||
}(&following)
|
}(&following)
|
||||||
// Remove limits on the size of data items that we'll retrieve.
|
// Remove limits on the size of data items that we'll retrieve.
|
||||||
rc = C.sd_journal_set_data_threshold(j, C.size_t(0))
|
rc = C.sd_journal_set_data_threshold(j, C.size_t(0))
|
||||||
|
|
Loading…
Reference in New Issue