<div dir="ltr"><div>From: Yicheng Qin &lt;<a href="mailto:yichengq@google.com">yichengq@google.com</a>&gt;</div><div>Subject: [PATCH] test/zdtm/sockets_dgram: check the length of path used</div><div><br></div><div>Path generated in the test is copied into sun_path attribute in</div>
<div>struct sockaddr_un. Additional check on whether sun_path can</div><div>contain the whole path is added. It is useful because if sun_path</div><div>can only contain the first part of the path, all sockadd_un</div><div>
will point to the same location, which leads to error.</div><div><br></div><div>Signed-off-by: Yicheng Qin &lt;<a href="mailto:yichengq@google.com">yichengq@google.com</a>&gt;</div><div>---</div><div> test/zdtm/live/static/sockets_dgram.c | 12 ++++++++++++</div>
<div> 1 file changed, 12 insertions(+)</div><div><br></div><div>diff --git a/test/zdtm/live/static/sockets_dgram.c b/test/zdtm/live/static/sockets_dgram.c</div><div>index b914111..1df0570 100644</div><div>--- a/test/zdtm/live/static/sockets_dgram.c</div>
<div>+++ b/test/zdtm/live/static/sockets_dgram.c</div><div>@@ -73,18 +73,30 @@ int main(int argc, char *argv[])</div><div> </div><div>        snprintf(path, sizeof(path), &quot;%s/%s.bound&quot;, cwd, filename);</div><div>
        unlink(path);</div><div>+       if (strlen(path) &gt;= sizeof(name_bound.sun_path)) {</div><div>+               fail(&quot;too long path&quot;);</div><div>+               exit(1);</div><div>+       }</div><div> </div>
<div>        name_bound.sun_family = AF_UNIX;</div><div>        strncpy(name_bound.sun_path, path, sizeof(name_bound.sun_path));</div><div> </div><div>        snprintf(path, sizeof(path), &quot;%s/%s.conn&quot;, cwd, filename);</div>
<div>        unlink(path);</div><div>+       if (strlen(path) &gt;= sizeof(name_conn.sun_path)) {</div><div>+               fail(&quot;too long path&quot;);</div><div>+               exit(1);</div><div>+       }</div><div>
 </div><div>        name_conn.sun_family = AF_UNIX;</div><div>        strncpy(name_conn.sun_path, path, sizeof(name_conn.sun_path));</div><div> </div><div>        snprintf(path, sizeof(path), &quot;%s/%s.bound-conn&quot;, cwd, filename);</div>
<div>        unlink(path);</div><div>+       if (strlen(path) &gt;= sizeof(name_bound_conn.sun_path)) {</div><div>+               fail(&quot;too long path&quot;);</div><div>+               exit(1);</div><div>+       }</div>
<div> </div><div>        name_bound_conn.sun_family = AF_UNIX;</div><div>        strncpy(name_bound_conn.sun_path, path, sizeof(name_bound_conn.sun_path));</div></div>