Commit Graph

12 Commits

Author SHA1 Message Date
Paul Holzinger d40e25cd45 fix panic in Writer
Commit 766cfece introduced this bug by defining an incorrect split
function. First it breaks the old behavior because it never splits at
newlines now. Second, it causes a panic because it never tells the
scanner to stop. See the bufio.ScanLines function, something like:
```
if atEOF && len(data) == 0 {
	return 0, nil, nil
}
```
is needed to do that.

This commit fixes it by restoring the old behavior and calling
bufio.ScanLines but also keep the 64KB check in place to avoid buffering
for to long.

Two tests are added to ensure it is working as expected.

Fixes #1383

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-21 08:59:35 -04:00
Simon Eskildsen f9291a534c Revert "Revert "Merge pull request #1376 from ozfive/master""
This reverts commit 352781de90.
2023-05-21 08:59:03 -04:00
Simon Eskildsen 352781de90 Revert "Merge pull request #1376 from ozfive/master"
This reverts commit 6acd903758, reversing
changes made to e59b167d75.
2023-05-17 13:59:50 -04:00
Chris c052ba6a07
Scan text in 64KB chunks
This commit fixes a potential denial of service
vulnerability in logrus.Writer() that could be
triggered by logging text longer than 64KB
without newlines. Previously, the bufio.Scanner
used by Writer() would hang indefinitely when
reading such text without newlines, causing the
application to become unresponsive.
2023-05-04 12:10:48 +10:00
Chris 766cfece37 This commit fixes a potential denial of service vulnerability in logrus.Writer() that could be triggered by logging text longer than 64kb without newlines. Previously, the bufio.Scanner used by Writer() would hang indefinitely when reading such text without newlines, causing the application to become unresponsive. 2023-03-10 13:45:41 -08:00
Edward Muller 6cd8d684fd
some minimal documentation for Logger.Writer{,Level}
This also includes two examples extracted from the readme.
2019-09-05 19:34:46 -07:00
drampull 4981d8161c Added TRACE level logging. 2018-10-17 18:22:00 -07:00
David Glasser 1fccefa2f4 Add Writer and WriterLevel to Entry
This lets you do things like:

    cmd := exec.Command("command")
    stdout := logrus.WithField("fd", "stdout").Writer()
    defer stdout.Close()
    stderr := logrus.WithField("fd", "stderr").Writer()
    defer stderr.Close()
    cmd.Stdout = stdout
    cmd.Stderr = stderr
2017-03-06 16:24:57 -08:00
Antoine Grondin 218981bef4 use constant InfoLevel instead of 255 2016-04-16 12:46:11 +05:30
Damien Radtke 1d1fd2d9ce Add WriterLevel() function to the logger
This commit adds a variant of the logger's Writer() function that
accepts a log level. When the variant is used, any messages written to
the returned pipe will be written with the provided level. The original
Writer() function uses the logger's Print() method as it always has.
2016-04-16 12:45:27 +05:30
Anton Tiurin a8b793a1fc gofmt 2015-03-10 19:06:14 +03:00
Patrick Hemmer 51cbf81dde rename InputWriter -> Writer 2015-01-26 09:59:50 -05:00