troglobit/netcalc

pipe from stdin not working reliably

Closed this issue · 3 comments

Piping from stdin is not working reliably. Sometimes works. Sometimes not...

netcalc 2601:186:4503:8130::1/64
works
echo 2601:186:4503:8130::1/64 | netcalc -
fails
echo fe80::20d:b9ff:fe41:7155/64 | netcalc -
works

when it fails... it does not output anything, just returns to command prompt.

Thanks
David

@dkerr64 This appears to be a holdover from sipcalc's interface support and the size of IFNAMSIZ, which is usually 16, truncating the stdin argument. While some IPv6's seemed to work, they were not correct via stdin.

This hack makes it work.

--- a/netcalc.h	2017-02-24 10:31:18.000000000 -0600
+++ b/netcalc.h	2017-03-26 08:43:15.029904488 -0500
@@ -16,6 +16,8 @@
 #endif
 #include <err.h>		/* warnx() et al */
 #include <net/if.h>		/* IFNAMSIZ */
+#undef IFNAMSIZ
+#define IFNAMSIZ 128
 
 /*** Fallback to older types before stdint.h was defined ***/
 #ifndef HAVE_UINT8_T

With proper code examination, possibly I can create a PR to properly fix this.

Yeah, I've gotten lost too many times in the old argbox code ... started refactoring the whole mess today, but PR #8 is better in all respects until I get some time again sort my refactor out.

Merged, thanks!