]> git.ipfire.org Git - thirdparty/util-linux.git/commit
wall: use fputs_careful()
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Wed, 15 Mar 2023 15:16:48 +0000 (16:16 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 17 Mar 2023 10:48:41 +0000 (11:48 +0100)
commitaa13246a1bf1be9e4f6eb331f4d4d2dbc875e22f
tree166c719701cd9518448166a7b3e62c65414e2e92
parent27ee6446503af7ec0c2647704ca47ac4de3852ef
wall: use fputs_careful()

LINE_MAX only applies to teletypes in canonical mode: when stdin is a
file, it could still very much tear; start off at 512 for the sprintf(),
then use getline() like in write.

The line wrapping has one suboptimal edge-case:
  $ wall < all

  Broadcast message from nabijaczleweli@tarta (pts/4) (Tue Mar 14 22:31:25
  2023):

  ^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_
  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ
  KLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?\200\201\202\203\204\205\206
  \207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232
  \233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256
  \257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302
  \303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326
  \327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352
  \353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376
  \377
but that's a pathological input, and the result is still infinitely
better than it was before, so fixing that is more trouble than it's
worth.

Bug-Debian: https://bugs.debian.org/826596
include/carefulputc.h
login-utils/last.c
term-utils/wall.c
term-utils/write.c