[Tickets] [InitNG] #702: Segfault from history plugin

InitNG trac at initng.org
Tue Jul 18 16:24:39 CEST 2006


#702: Segfault from history plugin
-----------------------------------+----------------------------------------
 Reporter:  mark at errai.net         |       Owner:                 
     Type:  defect                 |      Status:  new            
 Priority:  normal                 |   Milestone:                 
Component:  Bugs in initng source  |     Version:  initng-0.6.8svn
 Severity:  normal                 |    Keywords:                 
-----------------------------------+----------------------------------------
 in function cmd_log, lines 224 and 229, the call to mprintf uses variable
 'name' which is
 initialised from current->name, current->service->name, or is NULL (set in
 lines 155-160).

 first case (name = current->name) seems to work when current->name is not
 NULL
 second case (name = current->service->name) for some reason has a junk
 pointer (and therefore, segfault)
 third case (name = NULL) always segfaults

 third case is easy to fix (patch attached) but second case.... i have no
 idea where current->service->name is being set, though current->service
 looks to be a junk pointer as well

 easily reproducable when fiddling around with NetworkManager - start it
 up, stop it a few times, print out the (full) log and BAM

 this was with rev 4465 from SVN. am happy to test this when its fixed.

 patch for third case:

 {{{
 --- initng_history.c    2006-07-19 00:18:55.000000000 +1000
 +++ initng_history.c.patched    2006-07-19 00:20:41.000000000 +1000
 @@ -156,8 +156,12 @@
                         name = current->name;
                 else if (current->service && current->service->name)
                         name = current->service->name;
 -               else
 -                       name = NULL;
 +               else {
 +                       // Causes segfault upon call to mprintf
 +                       // name = NULL;
 +                       name = (char*)malloc(13);
 +                       strcpy(name, "(No service)");
 +               }

                 if (last != current->time.tv_sec)
                 {
 }}}

-- 
Ticket URL: <http://www.initng.org/ticket/702>
InitNG <http://www.initng.org/>
The Next Generation InitSystem


More information about the Tickets mailing list