[vpn-devel] [Patch] qikea fails to list connections on Linux

Stefan Brüns stefan.bruens at rwth-aachen.de
Thu Jun 19 10:57:12 CDT 2014


Hi,

the directory listing code accesses the dirent structure after closedir. As 
the directory stream is invalidated, the dirent structure becomes invalid as 
well.

This can be fixed by either using readdir_r(...) or by delaying closedir after
the read access. I have chosen the second approach.

Kind regards,

Stefan

-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
phone: +49 241 53809034     mobile: +49 151 50412019
-------------- next part --------------
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <link href="/favicon.ico" rel="shortcut icon" />

    <title>File fix_dirent_access_after_closedir.patch of Package ike - openSUSE Build Service</title>

    <link href="/assets/webui/application-f36e48ba1fcd531f6a462eeafbc71643.css" media="screen" rel="stylesheet" />
      <style type="text/css">
	.CodeMirror {
height: ;
}

      </style>
    <script src="/assets/webui/application/cm2/index-2aba6fcbb6fd09e549aaca807dcded75.js"></script>

    <script src="/assets/webui/application-2a773e3f37195b4118621ec40d76308f.js"></script>
    <script>
//<![CDATA[

      
      var _paq = _paq || [];
      $(function() {
        
  $("#advanced_tabs_trigger").click(function() {
    $("#advanced_tabs").show();
    $("#advanced_list_item").hide();
  });
    use_codemirror(0, false, 'diff');

          callPiwik();  
      });

//]]>
</script>
    <link href="/main/news.rss" rel="alternate" title="News" type="application/rss+xml" />
    <meta content="authenticity_token" name="csrf-param" />
<meta content="jNz8uO3VoKHzDAULPPXaWbWknZW+KiAeY/KmGa7Kxgg=" name="csrf-token" />
  </head>
  <body>
        <!-- Start: Header -->
    <div id="header">

      <div id="header-content" class="container_12">

        <a href="/" id="header-logo"><img alt="header-logo" class="icons-header-logo" src="/assets/s-8b7c2848c5f63ac4d99124dc0b1525c8.gif" /></a>
      <ul id="global-navigation">
        <li id="item-downloads"><a href="http://en.opensuse.org/openSUSE:Browse#Downloads">Downloads</a></li>
        <li id="item-support"><a href="http://en.opensuse.org/openSUSE:Browse#Support">Support</a></li>
        <li id="item-community"><a href="http://en.opensuse.org/openSUSE:Browse#Community">Community</a></li>
        <li id="item-development"><a href="http://en.opensuse.org/openSUSE:Browse#Development">Development</a></li>
            <li id="item-favorites" style="float: right;"><a href="https://build.opensuse.org/user/show/StefanBruens">Watchlist</a></li>
        </ul>

            <ul class="global-navigation-menu global-navigation-menu-favorites" id="menu-favorites">
      <li>
        <span class="desc">List of projects you are watching</span>
      </li>
          <li>
            <a id="toggle_watch" href="/project/toggle_watch/home:StefanBruens:branches:security">
                  <span>Add this project to Watchlist</span>
                  <span class="desc">Watch this project</span>
            </a>
          </li>
          <li>
            <a href="/project/show/X11:XOrg"><span class="project-link"><span class="icons-project"></span>X11:XOrg</span></a>
          </li>
    </ul>

<form accept-charset="UTF-8" action="/search" class="label-overlay" id="global-search-form" method="post"><div style="display:none"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="jNz8uO3VoKHzDAULPPXaWbWknZW+KiAeY/KmGa7Kxgg=" /></div>    <div style="display: inline">
      <label for="search" class="hidden">Search</label>
      <input id="search" name="search_text" type="text" value="" />      <input type="submit" value="Search" class="hidden"/>
    </div>
</form>


      </div>
    </div>
    <!-- End: Header -->



    <div id="subheader" class="container_16">
      <div id="breadcrump" class="grid_10 alpha">
        <img alt="Logo" class="icons-home_grey" src="/assets/s-8b7c2848c5f63ac4d99124dc0b1525c8.gif" title="Logo" /><a href="/">openSUSE Build Service</a>
            >
                          <a href="/project/list_public">Projects</a>
            >
             <!-- multiple items in crump list but they belong together as sub group, eg sub projects -->
              <a href="/project/show/home:StefanBruens">home:StefanBruens</a>:<a href="/project/show/home:StefanBruens:branches:security">branches:security</a>
            >
                          <a href="/package/show/home:StefanBruens:branches:security/ike">ike</a>
            >
                          fix_dirent_access_after_closedir.patch
      </div>

      <div class="grid_6 omega" style="text-align: right">
      <a href="/user/show/StefanBruens" id="link-to-user-home">
	StefanBruens
</a>      <a href="/user/show/StefanBruens" title="where an action is requested from you">
	 (7 tasks)
</a> |
    <a href="/project/show/home:StefanBruens">Home Project</a> |
    <a data-method="post" href="/user/logout" id="logout-link" rel="nofollow">Logout</a>
</div>

    </div>

    


    <!-- this is needed for the delete confirm dialogues -->
    <div id="dialog_wrapper" style="display: none"></div>

    <!-- Start: Main Content Area -->
    <div id="content" class="container_16 content-wrapper">
        <div class="grid_16 box box-shadow alpha omega">
          

<div class="box-header header-tabs" id="package_tabs">
  <ul>
    <li id="tab-overview"><a href="/package/show/home:StefanBruens:branches:security/ike">Overview</a></li>
      <li id="tab-repositories"><a href="/package/repositories/home:StefanBruens:branches:security/ike">Repositories</a></li>
      <li id="tab-revisions"><a href="/package/revisions/home:StefanBruens:branches:security/ike">Revisions</a></li>
      <li id="tab-requests"><a href="/package/requests/home:StefanBruens:branches:security/ike">Requests</a></li>
      <li id="tab-users"><a href="/package/users/home:StefanBruens:branches:security/ike">Users</a></li>
      <li id="advanced_list_item"><a href="#" id="advanced_tabs_trigger">Advanced</a></li>
  </ul>
    <div id="advanced_tabs" class="hidden">
      <ul>
        <li id="tab-attributes"><a href="/package/attributes/home:StefanBruens:branches:security/ike">Attributes</a></li>
        <li id="tab-meta"><a href="/package/meta/home:StefanBruens:branches:security/ike">Meta</a></li>
      </ul>
    </div>
</div>


<h3>File fix_dirent_access_after_closedir.patch of Package ike </h3>


    

    <div id="top_0">
      <div class="toolbar">
    <span style="float:left;">
      <input type="button" class="tools buttons small save inactive" value="Save" id="save_0"/>
      <input type="button" id="undo_0" value="undo" class="tools
      buttons undo" style="background:transparent;" onclick="editors[0].Undo(this);"/>
      
      <input type="button" id="redo_0" value="redo" class="tools
      buttons redo" style="background:transparent;" onclick="editors[0].Redo(this);"/>

      <!-- span class="text">search:</span>
      <input type="button" class="tools buttons small" value="off" id="search_disable_0"  />
      <input disabled="disabled" type="text"  class="tools inputs"
      style="background:transparent" id="search_0"  autocomplete="off" placeholder="type or select" onkeydown="this.style.background = '';" />
      <span id="prenex_0" style="display:none;">
        <input type="button" class="tools buttons prev" value="◄"
        id="prev_0" onclick="editors[0].Prev(this)" />
        <input type="button" class="tools buttons next" value="►"
        id="next_0" onclick="editors[0].Next(this)" />
      </span>
      <input type="button" class="tools buttons" style="width:36px;" value="find" id="find_0" />
       
      <span class="text">replace:</span>
      <input disabled="disabled" type="text" class="tools inputs" style="background:transparent" id="replace_0"  autocomplete="off" />
      <input type="button" class="tools buttons medium" value="replace" onclick="editors[0].Replace(this);" />
      <input type="button" class="tools buttons medium" value="replace all" onclick="editors[0].ReplaceAll(this);" />
        
-->
    </span>
 
    <span style="float:right;">

      <select class="tools select" id="fontsize_0" onchange="editors[0].updateFontsize(this)">
        <option value="8pt"> 8pt</option>
        <option value="9pt"> 9pt</option>
        <option value="10pt"> 10pt</option>
        <option value="11pt"> 11pt</option>
        <option value="12pt"> 12pt</option>
        <option value="14pt"> 14pt</option>
      </select>
      <select class="tools select" id="mode_0" onchange="editors[0].updateMode(this)">
        <option id="changes_0" value="changes">changes</option>
        <option id="spec_0" value="spec">spec</option>
        <option id="diff_0" value="diff">diff</option>
        <option id="shell_0" value="text/x-sh">shell</option>
        <option id="prjconf_0" value="prjconf">projconf</option>
        <option id="baselibs_0" value="baselibsconf">baselibs</option>
        <option id="perl_0" value="perl">perl</option>
        <option id="css_0" value="css"> css</option>
        <option id="html_0" value="htmlmixed"> html</option>
        <option id="js_0" value="javascript"> js</option>
        <option id="php_0" value="application/x-httpd-php-open"> php</option>
        <option id="xml_0" value="xml"> xml</option>
        <option id="x_0" selected="selected" value=""> ---</option>
      </select>
    </span>
      </div>
    </div>

<textarea class="editor" cols="0" data-data="{"project":"home:StefanBruens:branches:security","package":"ike","submit":"file","comment":"","filename":"fix_dirent_access_after_closedir.patch","rev":null}" data-save-method="POST" data-save-url="/package/save_modified_file/home:StefanBruens:branches:security/ike?method=post" id="editor_0" rows="0" style="display: inline-block">
diff --git a/source/libike/manager.file.cpp b/source/libike/manager.file.cpp
index 67a50ad..4d81c98 100644
--- a/source/libike/manager.file.cpp
+++ b/source/libike/manager.file.cpp
@@ -107,12 +107,14 @@ bool _CONFIG_MANAGER::file_enumerate( CONFIG & config, int & index )
 		found++;
 	}
 
-	closedir( dirp );
-	if( dp == NULL )
+	if( dp == NULL ) {
+		closedir( dirp );
 		return false;
+        }
 
 	config.set_id( dp->d_name );
 	index++;
+	closedir( dirp );
 
 	return file_vpn_load( config );
 
</textarea>

    <div id="bottom_0">
      <div class="toolbar">
    <span style="float:left;">
      <span class="text">position</span>
        
      <span class="text">line:</span>
      <span id="ln_0" class="text" style="display:inline-block;width:40px;">0</span>
      <span class="text">char:</span>
      <span id="ch_0" class="text" style="display:inline-block;width:40px;">0</span>
        
      <span class="text">tab size:</span>
      <select class="tools select" style="min-width:30px;" id="tabsize_0" onchange="editors[0].updateTabsize(this)">
        <option value="2"> 2</option>
        <option value="3"> 3</option>
        <option value="4"> 4</option>
        <option value="5"> 5</option>
        <option value="6"> 6</option>
        <option value="7"> 7</option>
        <option value="8"> 8</option>
      </select>
    </span>
    <span style="float:left;">
      <span class="text">matching:</span>
      <input type="button" class="tools buttons small" id="match_0" value="off" onclick="editors[0].Match(this);"/>
    </span>
    <span style="float:right;">
      <span class="text">line:</span>
      <input type="text" id="line_0" class="tools inputs" autocomplete="off" style="width:30px;"/>
      <input type="button" class="tools buttons small" value="go" onclick="editors[0].gotoLine(this);"/>
        
      <span class="text">line wrapping:</span>
      <input type="button" class="tools buttons small" value="off" onclick="editors[0].Wrap(this)"/>
    </span>
      </div>
    </div>



        </div>
    </div>
    <!-- End: Main Content Area -->

    <div style="clear: both;"></div>

    <div id="footer" class="container_12">
      <div class="grid_3">
        <strong class="grey-medium spacer1"><a href="/user/show/StefanBruens">StefanBruens</a>:</strong>
        <ul>
          <li><a href="/user/show/StefanBruens">Your Profile</a> </li>
          <li><a href="/project/show/home:StefanBruens">Home Project</a></li>
          <li><a data-method="post" href="/user/logout" rel="nofollow">Logout</a></li>
        </ul>
      </div>

      <div class="grid_3">
        <strong class="grey-medium spacer1">Locations</strong>
        <ul>
          <li><a href="/project/list_public">Projects</a></li>
          <li><a class="search-link" href="/search">Search</a></li>
            <li><a href="/monitor">Status Monitor</a></li>
        </ul>
      </div>

      <div class="grid_3">
        <strong class="grey-medium spacer1">Help</strong>
        <ul>
              <li><a href="http://openbuildservice.org/">Open Build Service</a></li>
              <li><a href="http://openbuildservice.org/help/manuals/">OBS Manuals</a></li>
              <li><a href="http://en.opensuse.org/Portal:Build_service">openSUSEs OBS Portal</a></li>
              <li><a href="http://openbuildservice.org/support/">Reporting a Bug</a></li>
        </ul>
      </div>

      <div class="grid_3">
        <strong class="grey-medium spacer1">Contact</strong>
        <ul>
               <li><a href="http://lists.opensuse.org/opensuse-buildservice/">Mailing List</a></li>
               <li><a href="http://forums.opensuse.org/forumdisplay.php/692-Open-Build-Service-%28OBS%29">Forums</a></li>
               <li><a href="irc://irc.opensuse.org/opensuse-buildservice">Chat (IRC)</a></li>
               <li><a href="http://twitter.com/OBShq">Twitter</a></li>
        </ul>
      </div>
      <div class="clear"></div>  
      <div id="footer-legal" class="grid_12">
        <p>
          <a href="http://openbuildservice.org">Open Build Service (OBS)</a> is an <a href="http://www.opensuse.org">openSUSE project</a>.
        </p>
      </div>
    </div>
  </body>
</html>


More information about the vpn-devel mailing list