[PATCH v2] whois: It is safe to tell fgets() the entire size of the buffer
Xabier Oneca -- xOneca
xoneca at gmail.com
Tue Dec 3 14:41:01 UTC 2019
fgets() reads in at most one less than size characters from stream, so no need
to account for the extra byte needed for the final '\0'. In fact, it was never
set to '\0' if fgets() did not do it.
Signed-off-by: Xabier Oneca <xoneca at gmail.com>
---
networking/whois.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/networking/whois.c b/networking/whois.c
index caa71ac..813b34f 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -54,7 +54,7 @@ static char *query(const char *host, int port, const
char *domain)
success = 0;
while (bufpos < 32*1024 /* paranoia */
- && fgets(linebuf, sizeof(linebuf)-1, fp)
+ && fgets(linebuf, sizeof(linebuf), fp)
) {
unsigned len;
--
2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-whois-It-is-safe-to-tell-fgets-the-entire-size-of.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20191203/80b49f16/attachment.bin>
More information about the busybox
mailing list