diff options
| author | Kristian Høgsberg <krh@bitplanet.net> | 2012-08-03 22:39:51 -0400 |
|---|---|---|
| committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-08-03 22:39:51 -0400 |
| commit | 915cdeee29291332384c4cf9ee67758e19500131 (patch) | |
| tree | ea08a3d87bd5d87f80ecfaa8ba1ddc7505aa95e4 /src/connection.c | |
| parent | protocol: Remove "repeat" from "key_state" (diff) | |
| download | wayland-915cdeee29291332384c4cf9ee67758e19500131.tar wayland-915cdeee29291332384c4cf9ee67758e19500131.tar.gz wayland-915cdeee29291332384c4cf9ee67758e19500131.tar.bz2 wayland-915cdeee29291332384c4cf9ee67758e19500131.tar.lz wayland-915cdeee29291332384c4cf9ee67758e19500131.tar.xz wayland-915cdeee29291332384c4cf9ee67758e19500131.tar.zst wayland-915cdeee29291332384c4cf9ee67758e19500131.zip | |
connection: zero out string padding
We don't want to send random data to the client and this also keeps
valgrind happy.
Diffstat (limited to 'src/connection.c')
| -rw-r--r-- | src/connection.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/connection.c b/src/connection.c index 2733ac9..9a5381e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -436,7 +436,7 @@ wl_closure_vmarshal(struct wl_object *sender, { struct wl_closure *closure; struct wl_object **objectp, *object; - uint32_t length, *p, *start, size, *end; + uint32_t length, aligned, *p, *start, size, *end; int dup_fd; struct wl_array **arrayp, *array; const char **sp, *s; @@ -497,7 +497,8 @@ wl_closure_vmarshal(struct wl_object *sender, goto err_null; length = s ? strlen(s) + 1: 0; - if (p + DIV_ROUNDUP(length, sizeof *p) + 1 > end) + aligned = (length + 3) & ~3; + if (p + aligned / sizeof *p + 1 > end) goto err; *p++ = length; @@ -507,7 +508,8 @@ wl_closure_vmarshal(struct wl_object *sender, *sp = NULL; memcpy(p, s, length); - p += DIV_ROUNDUP(length, sizeof *p); + memset((char *) p + length, 0, aligned - length); + p += aligned / sizeof *p; break; case 'o': closure->types[i] = &ffi_type_pointer; |
