[Toybox] [PATCH] macOS: fix uname.

enh enh at google.com
Fri Nov 30 14:49:51 PST 2018


Don't hard-code Linux's buffer size.
---
 toys/posix/uname.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/toys/posix/uname.c b/toys/posix/uname.c
index 2e17d387..a1338415 100644
--- a/toys/posix/uname.c
+++ b/toys/posix/uname.c
@@ -41,12 +41,13 @@ config UNAME
 void uname_main(void)
 {
   int i, flags = toys.optflags, needspace=0;
+  struct utsname u;

-  uname((void *)toybuf);
+  uname(&u);

   if (!flags) flags = FLAG_s;
   for (i=0; i<5; i++) {
-    char *c = toybuf+(65*i);
+    char *c = ((char *) &u)+(sizeof(u.sysname)*i);

     if (flags & ((1<<i)|FLAG_a)) {
       int len = strlen(c);
-- 
2.20.0.rc1.387.gf8505762e3-goog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-macOS-fix-uname.patch
Type: text/x-patch
Size: 850 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20181130/38ccadce/attachment-0002.bin>


More information about the Toybox mailing list