Wouldn't this be simpler?<div><br></div><div><span style>snprintf(path, sizeof path, "%s/%s", </span><span style>MODULEDIR, </span><span style>name);</span></div><div><br><div class="gmail_quote">On Wed, May 23, 2012 at 11:32 PM, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@linux.intel.com" target="_blank">chad.versace@linux.intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the MODULEDIR string contains '%', then<br>
snprintf(path, sizeof(path), MODULEDIR "/%s", name);<br>
does not do what you want.<br>
<br>
Fix this by replacing snprintf with stncpy followed by strncat.<br>
<br>
Signed-off-by: Chad Versace <<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>><br>
---<br>
src/compositor.c | 8 +++++---<br>
1 file changed, 5 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compositor.c b/src/compositor.c<br>
index 3c1e058..e556e70 100644<br>
--- a/src/compositor.c<br>
+++ b/src/compositor.c<br>
@@ -2773,10 +2773,12 @@ load_module(const char *name, const char *entrypoint, void **handle)<br>
char path[PATH_MAX];<br>
void *module, *init;<br>
<br>
- if (name[0] != '/')<br>
- snprintf(path, sizeof path, MODULEDIR "/%s", name);<br>
- else<br>
+ if (name[0] != '/') {<br>
+ strncpy(path, MODULEDIR "/", sizeof(path) - 1);<br>
+ strncat(path, name, sizeof(path) - sizeof(MODULEDIR "/") - 1);<br>
+ } else {<br>
snprintf(path, sizeof path, "%s", name);<br>
+ }<br>
<br>
module = dlopen(path, RTLD_LAZY);<br>
if (!module) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.2<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>