9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] /sys/src/cmd/awk/maketab.c
@ 2017-06-02 17:04 cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2017-06-02 17:04 UTC (permalink / raw)
  To: 9front

changeset:   6000:af6349c94998
tag:         tip
user:        cinap_lenrek@felloff.net
date:        Fri Jun 02 19:03:37 2017 +0200
summary:     awk: handle bad/incomplete input in maketab (thanks kenji arisawa)

diff -r 893500fd84bc -r af6349c94998 sys/src/cmd/awk/maketab.c
--- a/sys/src/cmd/awk/maketab.c	Fri Jun 02 17:10:52 2017 +0200
+++ b/sys/src/cmd/awk/maketab.c	Fri Jun 02 19:03:37 2017 +0200
@@ -133,8 +133,8 @@
 	i = 0;
 	while ((buf = Brdline(fp, '\n')) != nil) {
 		buf[Blinelen(fp)-1] = '\0';
-		tokenize(buf, toks, 3);
-		if (toks[0] == nil || strcmp("#define", toks[0]) != 0)	/* not a valid #define */
+		if (tokenize(buf, toks, 3) != 3
+		|| strcmp("#define", toks[0]) != 0)	/* not a valid #define */
 			continue;
 		tok = strtol(toks[2], nil, 10);
 		if (tok < FIRSTTOKEN || tok > LASTTOKEN) {

--
cinap


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] /sys/src/cmd/awk/maketab.c
@ 2017-06-02 16:58 cinap_lenrek
  0 siblings, 0 replies; 2+ messages in thread
From: cinap_lenrek @ 2017-06-02 16:58 UTC (permalink / raw)
  To: 9front

>-		tokenize(buf, toks, 3);
>-		if (toks[0] == nil || strcmp("#define", toks[0]) != 0)	/* not a valid #define */
>+		n = tokenize(buf, toks, 3);
>+		if (n == 0 || strcmp("#define", toks[0]) != 0)	/* not a valid #define */
> 			continue;
> 		tok = strtol(toks[2], nil, 10);

shouldnt that be like n != 3 instead? otherwise the "strtol(toks[2]..."
might also access uninitialized data.

--
cinap


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-02 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 17:04 [9front] /sys/src/cmd/awk/maketab.c cinap_lenrek
  -- strict thread matches above, loose matches on Subject: below --
2017-06-02 16:58 cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).