aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-03-03 23:30:45 -0500
committerMatthew Heon <mheon@redhat.com>2019-03-03 23:30:45 -0500
commitff609a5ade6991ef1d8f892a7bce44a039fbe174 (patch)
tree868670d0e950fed50c0b0680cad59a886bc59303
parent429f2e63a0e2a3b1e084371ebed280a6288b7617 (diff)
downloadpodman-ff609a5ade6991ef1d8f892a7bce44a039fbe174.tar.gz
podman-ff609a5ade6991ef1d8f892a7bce44a039fbe174.tar.bz2
podman-ff609a5ade6991ef1d8f892a7bce44a039fbe174.zip
Add additional defense against 0-length log segfaults
Signed-off-by: Matthew Heon <mheon@redhat.com>
-rw-r--r--pkg/logs/logs.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go
index 1d920d691..bbd5509b1 100644
--- a/pkg/logs/logs.go
+++ b/pkg/logs/logs.go
@@ -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.