Menu

#35 segfault in get_threadname in pstree.c

Next Release
pending
None
1
2015-03-24
2014-10-31
No

There is a problem in the get_threadname in pstree.c. Using the latest version (22.21) At line 808, file = fopen(...). If this fails the routine still tries to
do:

fclose(file);

Where file will be null. This causes a segfault. The fix is simple:

if (file) fclose(file);

at line 822.

Discussion

  • Craig Small

    Craig Small - 2014-12-22

    Patch [#33] had a few changes around this part of the code and as a side-effect (or intention) fixed this problem another way. It went into the repository at commit [265fa4]

     

    Related

    Commit: [265fa4]
    Patches: #33


    Last edit: Craig Small 2014-12-22
  • Craig Small

    Craig Small - 2014-12-22
    • status: open --> pending
    • assigned_to: Craig Small
     
  • Dr. Werner Fink

    Dr. Werner Fink - 2015-03-24

    Indeed this fix the crash on fclose() but there could be an other problem as well. After the malloc() for the threadname it might help to set

    *threadname = '\0';

    as otherwise strncpy() in new_proc() or rename_proc() may crash on random memory within the allocated area to which threadname points to.

     

Log in to post a comment.