Commit graph

3931 commits

Author SHA1 Message Date
Sören Tempel
c53230037a sam: use get9root instead of duplicating the logic 2022-07-27 10:15:51 -04:00
Sören Tempel
521fc08180 lib9: pass $PLAN9_TARGET via CPP for get9root fallback value
Allows this function to always return the proper path in situations
where the $PLAN9 environment variable is not set, i.e. a rc login shell.
2022-07-27 10:15:51 -04:00
Sören Tempel
f7b572818c INSTALL: Always set PLAN9_TARGET environment variable
That is, not only when -r was given. This allows using this veriable in
mkfiles across the code base.
2022-07-27 10:15:51 -04:00
camsn0w
005ee081d5 Added a paren to fix a warning in u.h 2022-07-26 18:27:34 -04:00
lufia
8d5bcf7e1e factotum: plug a memory leak in apop 2022-07-26 12:19:14 -04:00
Xiao-Yong Jin
1fcdefc585 fontsrv: always compute new height and ascent for the font file 2022-07-26 12:15:07 -04:00
Xiao-Yong Jin
85bfd19a7b devdraw/x11: fix modifier key handling for some XkbOptions
Certain XkbOptions in X11 would change keysyms for modifier keys
between the key press and key release.

For example, under the XkbOptions "grp:shifts_toggle", though shift
keys remain Shift_L/R when pressed, they become ISO_Group_Next/Prev
when released.

This behavior makes devdraw unable to detect the release event
correctly and as a result mouse button 1 click always interpreted
as button 3 event after a shift key is used.
2022-07-26 12:13:13 -04:00
Igor Böhm
07b24459ea Bail out if convW2M(...) indicates failure. 2022-07-26 12:12:05 -04:00
Igor Böhm
d92ac2d1b4 libdraw: fix out-of-bounds access to local buffer in event.c:startrpc()
The function `startrpc()` stack allocates a local buffer of size 100:

```c
static Muxrpc*
startrpc(int type)
{
	uchar buf[100];
	      ^^^^^^^^
	Wsysmsg w;

	w.type = type;
	convW2M(&w, buf, sizeof buf);
	return muxrpcstart(display->mux, buf);
}
```

The function `convW2M()` is called passing `buf`. That function accesses
`buf` out-of-bounds:

```c
uint
convW2M(Wsysmsg *m, uchar *p, uint n)
{
  ...
  case Tcursor2:
    PUT(p+6, m->cursor.offset.x);
    PUT(p+10, m->cursor.offset.y);
    memmove(p+14, m->cursor.clr, sizeof m->cursor.clr);
    memmove(p+46, m->cursor.set, sizeof m->cursor.set);
    PUT(p+78, m->cursor2.offset.x);
    PUT(p+82, m->cursor2.offset.y);
    memmove(p+86, m->cursor2.clr, sizeof m->cursor2.clr);
    memmove(p+214, m->cursor2.set, sizeof m->cursor2.set);
    p[342] = m->arrowcursor;
    ^^^^^^
```

To fix the issue the size of local variable `buf` is increased from 100
to 512 to avoid out-of-bounds array access.
2022-07-26 12:12:05 -04:00
Fazlul Shahriar
2ca8ede24a fossil: fix EOF detection when reading 9P message
When the 9P connection is closed, reads on the connection will keep
returning 0. So, fossil ends up looping forever, trying to read a 9P
message, consuming 100% CPU. The fix interprets 0 bytes read as EOF.

Reproduce by killing the 9pserve process serving the fossil service, or
by listening on tcp and using 9p(1).
2022-07-26 12:11:38 -04:00
mmnmnnmnmm
23420c2493 deroff: fix out-of-bounds access if runes above 0X80 are inside EQ clauses 2022-07-26 12:09:57 -04:00
Andriy Symonovych
a2422a89c5 trim button & modbutton images 2022-07-26 12:08:03 -04:00
Andriy Symonovych
6f35cfa6b6 make sure border has correct height 2022-07-26 12:07:00 -04:00
Kyle Nusbaum
bb4b8acc26 src/cmd/fontsrv: pad subfile names to support correct file length
For fonts with subfiles that go beyond the xffff range, the font file size
calculation is incorrect, since lines beyond that range have additional
characters. This patch pads all of the ranges and subfont names with
leading zeros in order to keep them all lines the same length and fixes the
font file length calculation.
2022-07-26 12:06:12 -04:00
Ben Huntsman
686f5d035c acme: Don't move the mouse if button depressed
Fixes #19
2022-07-26 12:04:01 -04:00
Ori Bernstein
964ac74cdc rc: remove dead code.
kencc warns that this code is dead.
2022-05-11 21:51:47 +00:00
Ben Huntsman
8bf462f339 man/man3/stat.3: Update man page to match include/libc.h. Resolves Issue #530 2022-05-11 21:46:32 +00:00
Russ Cox
bab7b73b85 INSTALL: build arm64 binaries on arm64 Macs
If there is any x86 binary in the chain of parent processes from
the current one, then uname -m prints x86_64 and clang
defaults to building x86_64 binaries.

Detect arm64 using the kernel version and force building
an arm64 toolchain instead of perpetuating x86.

This is particularly important when the user shell is rc,
which has been built for x86, because then rebuilding
under rc continues to use x86.
2022-01-24 13:47:27 -05:00
Roger Peppe
d0d440860f
src/cmd/acme: provide info on presense or absence of undo history (#528)
It's sometimes useful to know whether there's been editing activity
in a window. This PR adds that information to the ctl file.

Change-Id: I21a342ac636dd5c7701b3ed560e3526867329c2c
2021-10-19 12:08:45 -04:00
Nicola Girardi
7b0b2065fa cmd/auxstats: improve network device name matcher in Linux 2021-10-18 16:41:11 -04:00
Nic
0ac2a105ae cmd/auxstats: improve wireless interface name matcher in Linux 2021-10-17 14:08:16 -04:00
Dan Cross
e683bdfa76 mk: provide a mechanism to default to rc
For cross-compiling plan9 from Unix, provide a way
to force `mk` to use `rc` instead of `sh` without
setting `MKSHELL` in individual `mkfile`s.

If the environment variable `FORCERCFORMK` is set,
`mk` will default to using `rc`, not `sh`.

Signed-off-by: Dan Cross <cross@gajendra.net>
2021-10-05 08:24:37 -04:00
Russ Cox
d3ee9f70e4 sam: fix spurious overwrite message
Fixes:

% sam -d
 -.
w foo
foo: (new file) #0
w foo
?warning: write might change good version of `foo'
2021-09-30 08:44:00 -04:00
Russ Cox
8cf52696be acme: fix extra print args 2021-09-28 13:07:33 -04:00
Alexander Kapshuk
ceb1ab90ff lib9p: Fix compile error
commit 385a6d5877 removed src/lib9p/_post.c
from the code base, but overlooked removing a reference to the
_post.o object file from the src/lib9p/mkfile.

This results in lib9p failing to compile:

* Running on Darwin...
* Compiler version:
	Apple clang version 12.0.5 (clang-1205.0.22.11)
* Building mk...
* Building everything (be patient)...
>>> mk: don't know how to make '/Users/sasha/plan9port_fork/lib/lib9p.a(_post.o)' in /Users/sasha/plan9port_fork/src/lib9p
mk: for i in ...  : exit status=exit(1)

Remove _post.o from the list of dependent object files from
src/lib9p/mkfile to have lib9p compile.

Fixes: 385a6d5877 ("lib9p: Remove postmountsrv (#505)")
2021-09-01 08:40:44 -04:00
Ben Huntsman
385a6d5877 lib9p: Remove postmountsrv (#505) 2021-08-30 21:03:41 -04:00
Ben Huntsman
aa01c23be6 .gitignore: Ignore some more things that get created during compile. 2021-08-30 21:02:29 -04:00
Ben Huntsman
d356d2a8b2 9term: Skip unnecessary ioctl call on AIX. 2021-08-30 19:40:49 -04:00
Ben Huntsman
e9d8c45168 libdraw: Fix GUI programs on AIX (#398) 2021-08-30 19:40:49 -04:00
Ben Huntsman
6c4260fc67 bin/9c, bin/9l: Re-enable optimization on AIX. 2021-08-30 19:40:49 -04:00
Anthony Sorace
70cc6e5ba7 libthread: use setpgid instead of setpgrp 2021-04-22 08:44:27 -04:00
Russ Cox
93a25a0f97 install(1): mention libfontconfig1-dev for Debian
Also update install.txt, which mistakenly contained intro(1).

Pointed out by Nicholas Schwartz.
2021-04-09 15:23:55 -04:00
Günther Noack
878b30c0bc fspread: fix buffer overflow
Without this fix, fspread is trusting the server to return as much
data as requested, or less. If a server responds with more data
though, fspread writes beyond the bounds of the buffer to fill, which
is passed in by the caller. It depends on the caller of fspread()
where that buffer is, so there are various possible attack vectors.

In the Plan9 kernel, I found this implemented in devmnt.c, where
overly large responses are truncated to the size requested before
copying, so I assume that this strategy works here too.

This also affects fsread() and fsreadn(), which are based on
fspread().
2021-04-05 05:19:49 -04:00
Russ Cox
88a87fadae all: update for new MIT license
On March 23, 2021, Nokia transferred the copyrights in the Plan 9 software
to the Plan 9 Foundation, which relicensed them under the MIT license.

This commit updates the Plan 9 from User Space license to reflect the
new base license. The vast majority of the contributions beyond the
base Plan 9 set were by me, many of them explicitly under an MIT license.
Those are all under the new MIT license now as well.

The port of mk to Unix was taken from Inferno via Vita Nuova and had
been made available under GPL, but Vita Nuova has relicensed Inferno
under the MIT license as well, to match the new Plan 9 license.

Michael Teichgraber contributed src/lib9/zoneinfo.c explicitly under
the Lucent Public License but has agreed to change the contribution
to the MIT license now used in the rest of the distribution.

There remain a few exceptions, most notably fonts.
See the root LICENSE file for full details.

The only mention of the Lucent Public License in the whole tree now
is in the LICENSE file, explaining the history.
2021-03-23 20:59:23 -04:00
Russ Cox
a8bd9e9d8c mk: fix for Unix build 2021-03-23 20:54:29 -04:00
Russ Cox
73661401ea acme: fix double-free in acmeerrorproc
The receiver of cerr takes ownership of s.
2021-03-23 17:03:56 -04:00
Connor Taffe
90971376a5 mount: find kext with MacFUSE >=4 and macOS >=11 2021-01-31 20:52:49 -05:00
Connor Taffe
f62d4c4143 9pfuse: support MacFUSE >=4
MacFUSE 4 removes support for passing device fd to the mount command. Adds
support for the receiving the fd over a socket instead, and updates command paths
and filesystem name.
2021-01-31 20:52:49 -05:00
David Arroyo
a72478870a 9p: parse lines in rdwr command
Use bio(3) to read at most one line of input per iteration, even
if there is more than one line available in the input buffer. This
makes it easier to interact with line-oriented ctl files like that of
factotum(4) from shell scripts, without the need to control when
and how much data is flushed to a pipe.
2021-01-31 11:52:08 -05:00
Fazlul Shahriar
36cd4c58c1 man9: rename IM to MR
Commit d32deab17b renamed IM to MR but
these man pages were missed.
2021-01-29 19:33:10 -05:00
Xiao-Yong Jin
0144f87dc6 htmlroff: fix array bounds 2021-01-29 06:32:41 -05:00
Xiao-Yong Jin
4e6bb208eb eqn: enlarge errbuf to account for large tokens 2021-01-29 06:32:41 -05:00
Xiao-Yong Jin
20c14efad6 xd: fix swizz8 loop counting 2021-01-29 06:32:41 -05:00
Xiao-Yong Jin
4056d6be4d libhtml: fix array bounds in lex 2021-01-29 06:32:41 -05:00
Russ Cox
52b599a63c libthread: call setpgrp in programs that will background
This fixes the 'run stats from rc; exit rc; stats dies' problem.
It's unclear whether this is the right fix or whether rc should
be starting all its interactive commands in their own process
groups. But at least it does fix stats dying.
2021-01-14 10:30:24 -05:00
Russ Cox
3ccd61629b sam: avoid out-of-bounds read in rterm
Usually r->nused < r->nalloc and the read is in bounds.
But it could in theory be right on the line and reading
past the end of the allocation.

Make it safe but preserve as much of the old semantics
as possible. This use of rterm appears to be only for
optimization purposes so the result does not matter
for correctness.
2021-01-14 10:05:50 -05:00
Russ Cox
6a80119eb5 sam: remove backward ?:
The exit code here is ignored anyway.
2021-01-14 10:01:25 -05:00
Russ Cox
c3ae85a004 rc: do not exit on EINTR from read
This happens if lldb attaches to rc.
2021-01-14 09:59:54 -05:00
Russ Cox
0cc1faf015 lib9: reject postnote with special pids 2021-01-14 09:59:03 -05:00
Russ Cox
fdcf3d70c2 auxstats: do not postnote 0 2021-01-14 09:58:44 -05:00