Arondight/sudodev

Invalid read/write of size 1

Arondight opened this issue · 3 comments

This happend when delete the last device.

$ sudo sudodev del
[  1]  sdc2
Choose a device (q to quit): 1
Deleting device ... done
Reloading config ...    done

And here is log of valgrind.

==9978==                                                                                                                                                                                
==9978== HEAP SUMMARY:
==9978==     in use at exit: 0 bytes in 0 blocks
==9978==   total heap usage: 3,880 allocs, 3,880 frees, 7,936,335 bytes allocated
==9978== 
==9978== All heap blocks were freed -- no leaks are possible
==9978== 
==9978== ERROR SUMMARY: 4 errors from 2 contexts (suppressed: 0 from 0)
==9978== 
==9978== 2 errors in context 1 of 2:
==9978== Invalid read of size 1
==9978==    at 0x403EA0: readfile (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x402444: sighupHandler (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x4E46EFF: ??? (in /usr/lib/libpthread-2.23.so)
==9978==    by 0x510A4DF: __nanosleep_nocancel (in /usr/lib/libc-2.23.so)
==9978==    by 0x510A449: sleep (in /usr/lib/libc-2.23.so)
==9978==    by 0x401F7F: main (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==  Address 0x582640f is 1 bytes before a block of size 1 alloc'd
==9978==    at 0x4C2CB1D: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9978==    by 0x403E7A: readfile (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x402444: sighupHandler (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x4E46EFF: ??? (in /usr/lib/libpthread-2.23.so)
==9978==    by 0x510A4DF: __nanosleep_nocancel (in /usr/lib/libc-2.23.so)
==9978==    by 0x510A449: sleep (in /usr/lib/libc-2.23.so)
==9978==    by 0x401F7F: main (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978== 
==9978== 
==9978== 2 errors in context 2 of 2:
==9978== Invalid write of size 1
==9978==    at 0x4C31125: memset (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9978==    by 0x403E9F: readfile (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x402444: sighupHandler (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x4E46EFF: ??? (in /usr/lib/libpthread-2.23.so)
==9978==    by 0x510A4DF: __nanosleep_nocancel (in /usr/lib/libc-2.23.so)
==9978==    by 0x510A449: sleep (in /usr/lib/libc-2.23.so)
==9978==    by 0x401F7F: main (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==  Address 0x582640f is 1 bytes before a block of size 1 alloc'd
==9978==    at 0x4C2CB1D: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9978==    by 0x403E7A: readfile (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x402444: sighupHandler (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978==    by 0x4E46EFF: ??? (in /usr/lib/libpthread-2.23.so)
==9978==    by 0x510A4DF: __nanosleep_nocancel (in /usr/lib/libc-2.23.so)
==9978==    by 0x510A449: sleep (in /usr/lib/libc-2.23.so)
==9978==    by 0x401F7F: main (in /home/shell_way/Repo/my/sudodev/bin/sudodevd)
==9978== 
==9978== ERROR SUMMARY: 4 errors from 2 contexts (suppressed: 0 from 0)

此问题由提交 651d855 引入

Ref #12

● sudodevd.service - Create your special device for a none-password sudo
   Loaded: loaded (/usr/lib/systemd/system/sudodevd.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit-hit) since 四 2016-06-16 23:58:23 CST; 7s ago
     Docs: https://github.com/Arondight/sudodev
  Process: 12282 ExecStop=/bin/kill -TERM $MAINPID (code=exited, status=1/FAILURE)
  Process: 12279 ExecStart=/usr/bin/sudodevd (code=exited, status=0/SUCCESS)
 Main PID: 12280 (code=exited, status=0/SUCCESS)

6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Unit entered failed state.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Failed with result 'exit-code'.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Service hold-off time over, scheduling restart.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: Stopped Create your special device for a none-password sudo.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Start request repeated too quickly.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: Failed to start Create your special device for a none-password sudo.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Unit entered failed state.
6月 16 23:58:23 this-is-a-good-pc systemd[1]: sudodevd.service: Failed with result 'start-limit-hit'.

0 0 上面看错了,因为已经手动起了一个deamon,所以服务没起来,这不是BUG