<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:35:40 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Whamcloud Community JIRA</title>
    <link>https://jira.whamcloud.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.4.14</version>
        <build-number>940014</build-number>
        <build-date>05-12-2023</build-date>
    </build-info>


<item>
            <title>[LU-10502] Address of a local variable is returned through global variable &apos;progname&apos;.</title>
                <link>https://jira.whamcloud.com/browse/LU-10502</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;6559	static int lfs_mirror(int argc, char **argv)
6560	{
6561		char cmd[PATH_MAX];
6562		int rc = 0;
6563	 
6564		setlinebuf(stdout);
6565	 
6566		Parser_init(&quot;lfs-mirror &amp;gt; &quot;, mirror_cmdlist);
6567	 
6568		snprintf(cmd, sizeof(cmd), &quot;%s %s&quot;, progname, argv[0]);
6569		progname = cmd;
6570		program_invocation_short_name = cmd;
6571		if (argc &amp;gt; 1)
6572			rc = Parser_execarg(argc - 1, argv + 1, mirror_cmdlist);
6573		else
6574			rc = Parser_commands();
6575	 
6576		return rc &amp;lt; 0 ? -rc : rc;
6577	}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;TRACEBACK&lt;/p&gt;

&lt;p&gt;An event which alters the program&apos;s state, leading to the defect	&lt;br/&gt;
lfs.c:6569: Local address &apos;cmd&apos; is stored into &apos;progname&apos;&lt;/p&gt;

&lt;p&gt;An event which alters the program&apos;s state, leading to the defect	&lt;br/&gt;
lfs.c:6576: &apos;progname&apos; can be used outside&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Address of a local variable is returned through global variable &apos;program_invocation_short_name&apos;.&lt;/b&gt;&lt;br/&gt;
TRACEBACK&lt;/p&gt;

&lt;p&gt;An event which alters the program&apos;s state, leading to the defect	&lt;br/&gt;
lfs.c:6570: Local address &apos;cmd&apos; is stored into &apos;program_invocation_short_name&apos;&lt;/p&gt;

&lt;p&gt;An event which alters the program&apos;s state, leading to the defect	&lt;br/&gt;
lfs.c:6576: &apos;program_invocation_short_name&apos; can be used outside&lt;/p&gt;</description>
                <environment></environment>
        <key id="50201">LU-10502</key>
            <summary>Address of a local variable is returned through global variable &apos;progname&apos;.</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.whamcloud.com/images/icons/priorities/minor.svg">Minor</priority>
                        <status id="1" iconUrl="https://jira.whamcloud.com/images/icons/statuses/open.png" description="The issue is open and ready for the assignee to start work on it.">Open</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="yujian">Jian Yu</assignee>
                                    <reporter username="dmiter">Dmitry Eremin</reporter>
                        <labels>
                            <label>kw</label>
                            <label>patch</label>
                    </labels>
                <created>Fri, 12 Jan 2018 11:57:59 +0000</created>
                <updated>Sat, 29 Jan 2022 09:38:15 +0000</updated>
                                            <version>Lustre 2.11.0</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>5</watches>
                                                                            <comments>
                            <comment id="218168" author="yujian" created="Sat, 13 Jan 2018 00:19:55 +0000"  >&lt;p&gt;For &quot;lfs mirror&quot; commands, the progname needs to be replaced with &quot;lfs mirror&quot; instead of &quot;lfs&quot;, so progname was reassigned with cmd.&lt;/p&gt;</comment>
                            <comment id="218245" author="dmiter" created="Mon, 15 Jan 2018 09:55:23 +0000"  >&lt;p&gt;This issue here is a string is generated into local buffer! So, this local variable will be destroyed after exit from this function. I see a lot of places where progname is used. So, unexpectedly we can use garbage from stack instead of progname.&lt;/p&gt;</comment>
                            <comment id="218267" author="jay" created="Mon, 15 Jan 2018 18:56:10 +0000"  >&lt;p&gt;The current implementation won&apos;t have any issue per-se because as long as the function is returned &lt;tt&gt;progname&lt;/tt&gt; won&apos;t be used any more. However, I still think we should fix this issue otherwise it will throw a warning everything the static analysis tool is executed.&lt;/p&gt;

&lt;p&gt;The fix can be as simple as redefining &lt;tt&gt;progname&lt;/tt&gt; as:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; progname[PATH_MAX];
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="218473" author="yujian" created="Thu, 18 Jan 2018 02:41:30 +0000"  >&lt;p&gt;I tried to redefine progname in lfs.c but hit the following errors:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;lfs.c:77:13: error: conflicting types for &#8216;progname&#8217;
 static char progname[PATH_MAX];
             ^
In file included from lfs.c:64:0:
lfs_project.h:39:13: note: previous declaration of &#8216;progname&#8217; was here
 const char *progname;
             ^
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="218557" author="jay" created="Thu, 18 Jan 2018 19:00:51 +0000"  >&lt;p&gt;the &lt;tt&gt;progname&lt;/tt&gt; has been moved to &lt;tt&gt;lfs_project.c&lt;/tt&gt; by patch &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10030&quot; title=&quot;add native lfs tools support for project quota&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10030&quot;&gt;&lt;del&gt;LU-10030&lt;/del&gt;&lt;/a&gt;(the change seems to be wrong). We should restore the change to &lt;tt&gt;progname&lt;/tt&gt; and let &lt;tt&gt;lfs_project.c&lt;/tt&gt; and &lt;tt&gt;lfs.c&lt;/tt&gt; declare their own progname.&lt;/p&gt;</comment>
                            <comment id="218570" author="gerrit" created="Thu, 18 Jan 2018 20:23:36 +0000"  >&lt;p&gt;Jian Yu (jian.yu@intel.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/30928&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/30928&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10502&quot; title=&quot;Address of a local variable is returned through global variable &amp;#39;progname&amp;#39;.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10502&quot;&gt;LU-10502&lt;/a&gt; flr: redefine progname in lfs.c&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 91b1a3d24e46ac7cecbf66c08f92bb4a4a6b1500&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_10890" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzzr13:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10060" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Severity</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10022"><![CDATA[3]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>