Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plumber: fix EOF detection on writes to rules file #257

Merged
merged 1 commit into from
Sep 19, 2019

Conversation

fhs
Copy link
Contributor

@fhs fhs commented May 1, 2019

Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after gcc -O2 optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:

==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)

Fixes #256

Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after `gcc -O2` optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:
```
==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
```

Fixes 9fans#256
@dancrossnyc dancrossnyc merged commit b9424f6 into 9fans:master Sep 19, 2019
@fhs fhs deleted the plumber-write-rules branch September 19, 2019 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plumber: write to plumb/rules doesn't load rules from include statements
2 participants