diff options
| author | Ion Agorria <[email protected]> | 2024-01-05 09:22:10 +0200 |
|---|---|---|
| committer | Mattijs Korpershoek <[email protected]> | 2024-01-09 14:58:33 +0100 |
| commit | e58bafc35fe37491bb3546299593dcc054145adb (patch) | |
| tree | a50d65fe54980ff838d40d1a205433da49908d98 /lib | |
| parent | 90087dd076d42c196de3506b6fa4d052f0869670 (diff) | |
lib: membuff: fix readline not returning line in case of overflow
If line overflows readline it will not be returned, fix this behavior,
make it optional and documented properly.
Signed-off-by: Ion Agorria <[email protected]>
Signed-off-by: Svyatoslav Ryhel <[email protected]>
Reviewed-by: Mattijs Korpershoek <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mattijs Korpershoek <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/membuff.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/membuff.c b/lib/membuff.c index 3c6c0ae125c..b242a38ff1c 100644 --- a/lib/membuff.c +++ b/lib/membuff.c @@ -287,7 +287,7 @@ int membuff_free(struct membuff *mb) (mb->end - mb->start) - 1 - membuff_avail(mb); } -int membuff_readline(struct membuff *mb, char *str, int maxlen, int minch) +int membuff_readline(struct membuff *mb, char *str, int maxlen, int minch, bool must_fit) { int len; /* number of bytes read (!= string length) */ char *s, *end; @@ -309,7 +309,7 @@ int membuff_readline(struct membuff *mb, char *str, int maxlen, int minch) } /* couldn't get the whole string */ - if (!ok) { + if (!ok && must_fit) { if (maxlen) *orig = '\0'; return 0; |
