mirror of
https://github.com/containers/podman.git
synced 2025-06-22 01:48:54 +08:00
Add additional defense against 0-length log segfaults
Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
@ -313,11 +313,11 @@ func (w *logWriter) write(msg *logMessage) error {
|
||||
if w.opts.Timestamps && !w.doAppend {
|
||||
prefix := append([]byte(msg.timestamp.Format(timeFormat)), delimiter[0])
|
||||
line = append(prefix, line...)
|
||||
if line[len(line)-1] != '\n' {
|
||||
if len(line) > 0 && line[len(line)-1] != '\n' {
|
||||
w.doAppend = true
|
||||
}
|
||||
}
|
||||
if w.doAppend && line[len(line)-1] == '\n' {
|
||||
if w.doAppend && len(line) > 0 && line[len(line)-1] == '\n' {
|
||||
w.doAppend = false
|
||||
}
|
||||
// If the line is longer than the remaining bytes, cut it.
|
||||
|
Reference in New Issue
Block a user