<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content="text/html; charset=euc-kr" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: ±¼¸²Ã¼, arial; MARGIN-TOP: 5px
}
TD {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: ±¼¸²Ã¼, arial; MARGIN-TOP: 5px
}
LI {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: ±¼¸²Ã¼, arial; MARGIN-TOP: 5px
}
BODY {
        FONT-SIZE: 9pt; FONT-FAMILY: ±¼¸²Ã¼, arial; MARGIN: 10px; LINE-HEIGHT: 1.4
}
</STYLE>

<META content=IE=5 http-equiv=X-UA-Compatible>
<META content=IE=5 http-equiv=X-UA-Compatible>
<META name=GENERATOR content="MSHTML 11.00.9600.17924"></HEAD>
<BODY>
<P>Hi,</P>
<P>The os_exec() added with below patch last year, and the execv(program, argv) has been using in the os_exec() to run external programs.</P>
<P>However, we met 'execv:Exec format error'&nbsp;with this change&nbsp;when we used '-a' option.</P>
<P>Our Wi-Fi chip vendor said the execv() is not proper function, because the first argument of execv()&nbsp;is 'path' , not 'filename'.</P>
<P>And, they recommended we use execvp() or execve() instead.</P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int execv(const char *path, char *const argv[]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int execvp(const char *file, char *const argv[]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int execve(const char *filename, char *const argv[], char *const envp[]);</P>
<P>&nbsp;</P>
<P>Do you have&nbsp;any idea about this?</P>
<P>&nbsp;</P>
<P>---- previous patch ----</P>
<P>File : <A href="http://w1.fi/cgit/hostap/tree/">root</A>/<A href="http://w1.fi/cgit/hostap/tree/src">src</A>/<A href="http://w1.fi/cgit/hostap/tree/src/utils">utils</A>/<A href="http://w1.fi/cgit/hostap/tree/src/utils/os_unix.c">os_unix.c</A>&nbsp; </P>
<P>Commit message : Add os_exec() helper to run external programs</P>
<P>&nbsp;</P>
<P>
<TABLE class=commit-info summary="commit info">
<TBODY>
<TR>
<TH>author</TH>
<TD>Jouni Malinen &lt;jouni@qca.qualcomm.com&gt;</TD>
<TD class=right>2014-10-06 13:27:44 (GMT)</TD></TR>
<TR>
<TH>committer</TH>
<TD>Jouni Malinen &lt;j@w1.fi&gt;</TD>
<TD class=right>2014-10-09 14:38:25 (GMT)</TD></TR>
<TR>
<TH>commit</TH>
<TD class=sha1 colSpan=2><A href="http://w1.fi/cgit/hostap/commit/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0">89de07a9442072f88d49869d8ecd8d42bae050a0</A> (<A href="http://w1.fi/cgit/hostap/patch/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0">patch</A>)</TD></TR>
<TR>
<TH>tree</TH>
<TD class=sha1 colSpan=2><A href="http://w1.fi/cgit/hostap/tree/?id=89de07a9442072f88d49869d8ecd8d42bae050a0">4e59fd0b9fad4370fa1fdc65814530e6a4341591</A> /<A href="http://w1.fi/cgit/hostap/tree/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0">src/utils/os_unix.c</A></TD></TR>
<TR>
<TH>parent</TH>
<TD class=sha1 colSpan=2><A href="http://w1.fi/cgit/hostap/commit/src/utils/os_unix.c?id=74ed673f33934569d00d376694a7e97bc187a529">74ed673f33934569d00d376694a7e97bc187a529</A> (<A href="http://w1.fi/cgit/hostap/diff/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0&amp;id2=74ed673f33934569d00d376694a7e97bc187a529">diff</A>)</TD></TR>
<TR>
<TH>download</TH>
<TD class=sha1 colSpan=2><A href="http://w1.fi/cgit/hostap/snapshot/hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.zip">hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.zip</A><BR><A href="http://w1.fi/cgit/hostap/snapshot/hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.tar.gz">hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.tar.gz</A><BR><A href="http://w1.fi/cgit/hostap/snapshot/hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.tar.bz2">hostap-89de07a9442072f88d49869d8ecd8d42bae050a0.tar.bz2</A><BR></TD></TR></TBODY></TABLE></P>
<DIV class=commit-subject>Add os_exec() helper to run external programs<SPAN class=decoration></SPAN></DIV>
<DIV class=commit-msg>Signed-off-by: Jouni Malinen &lt;jouni@qca.qualcomm.com&gt; </DIV>
<DIV class=diffstat-header><A href="http://w1.fi/cgit/hostap/diff/?id=89de07a9442072f88d49869d8ecd8d42bae050a0">Diffstat</A> (limited to 'src/utils/os_unix.c')</DIV>
<P>
<TABLE class=diffstat summary=diffstat>
<TBODY>
<TR>
<TD class=mode>-rw-r--r--</TD>
<TD class=upd><A href="http://w1.fi/cgit/hostap/diff/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0">src/utils/os_unix.c</A></TD>
<TD class=right>55</TD>
<TD class=graph>
<TABLE width="55%" summary="file diffstat">
<TBODY>
<TR>
<TD class=add style="WIDTH: 100%">
<TD class=rem style="WIDTH: 0%">
<TD class=none style="WIDTH: 0%"></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></P>
<DIV class=diffstat-summary>1 files changed, 55 insertions, 0 deletions</DIV>
<P>
<TABLE class=diff summary=diff>
<TBODY>
<TR>
<TD>
<DIV class=head>diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c<BR>index 7498967..523a4d0 100644<BR>--- a/<A href="http://w1.fi/cgit/hostap/tree/src/utils/os_unix.c?id=74ed673f33934569d00d376694a7e97bc187a529">src/utils/os_unix.c</A><BR>+++ b/<A href="http://w1.fi/cgit/hostap/tree/src/utils/os_unix.c?id=89de07a9442072f88d49869d8ecd8d42bae050a0">src/utils/os_unix.c</A></DIV>
<DIV class=hunk>@@ -9,6 +9,7 @@</DIV>
<DIV class=ctx>#include "includes.h"</DIV>
<DIV class=ctx></DIV>
<DIV class=ctx>#include &lt;time.h&gt;</DIV>
<DIV class=add>+#include &lt;sys/wait.h&gt;</DIV>
<DIV class=ctx></DIV>
<DIV class=ctx>#ifdef ANDROID</DIV>
<DIV class=ctx>#include &lt;sys/capability.h&gt;</DIV>
<DIV class=hunk>@@ -554,3 +555,57 @@ char * os_strdup(const char *s)</DIV>
<DIV class=ctx>}</DIV>
<DIV class=ctx></DIV>
<DIV class=ctx>#endif /* WPA_TRACE */</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+int os_exec(const char *program, const char *arg, int wait_completion)</DIV>
<DIV class=add>+{</DIV>
<DIV class=add>+ pid_t pid;</DIV>
<DIV class=add>+ int pid_status;</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ pid = fork();</DIV>
<DIV class=add>+ if (pid &lt; 0) {</DIV>
<DIV class=add>+ perror("fork");</DIV>
<DIV class=add>+ return -1;</DIV>
<DIV class=add>+ }</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ if (pid == 0) {</DIV>
<DIV class=add>+ /* run the external command in the child process */</DIV>
<DIV class=add>+ const int MAX_ARG = 30;</DIV>
<DIV class=add>+ char *_program, *_arg, *pos;</DIV>
<DIV class=add>+ char *argv[MAX_ARG + 1];</DIV>
<DIV class=add>+ int i;</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ _program = os_strdup(program);</DIV>
<DIV class=add>+ _arg = os_strdup(arg);</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ argv[0] = _program;</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ i = 1;</DIV>
<DIV class=add>+ pos = _arg;</DIV>
<DIV class=add>+ while (i &lt; MAX_ARG &amp;&amp; pos &amp;&amp; *pos) {</DIV>
<DIV class=add>+ while (*pos == ' ')</DIV>
<DIV class=add>+ pos++;</DIV>
<DIV class=add>+ if (*pos == '\0')</DIV>
<DIV class=add>+ break;</DIV>
<DIV class=add>+ argv[i++] = pos;</DIV>
<DIV class=add>+ pos = os_strchr(pos, ' ');</DIV>
<DIV class=add>+ if (pos)</DIV>
<DIV class=add>+ *pos++ = '\0';</DIV>
<DIV class=add>+ }</DIV>
<DIV class=add>+ argv[i] = NULL;</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ execv(program, argv);</DIV>
<DIV class=add>+ perror("execv");</DIV>
<DIV class=add>+ os_free(_program);</DIV>
<DIV class=add>+ os_free(_arg);</DIV>
<DIV class=add>+ exit(0);</DIV>
<DIV class=add>+ return -1;</DIV>
<DIV class=add>+ }</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ if (wait_completion) {</DIV>
<DIV class=add>+ /* wait for the child process to complete in the parent */</DIV>
<DIV class=add>+ waitpid(pid, &amp;pid_status, 0);</DIV>
<DIV class=add>+ }</DIV>
<DIV class=add>+</DIV>
<DIV class=add>+ return 0;</DIV>
<DIV class=add>+}</DIV></TD></TR></TBODY></TABLE></P>
<P>&nbsp;</P>
<P>Thnaks,</P></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=60dc5d56177c6e7deece45bdb053f77d434febdc12633bf94f0866b595da094afd995074aa6f898d56fb541a27f7ff2caec275bafbc210b2a728c55b39cc59eacf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'>