Fix API to always include socket name length.

Kristian Høgsberg 16 years ago
parent cb70316105
commit dc0f355f0a
  1. 2
      egl-compositor.c
  2. 2
      flower.c
  3. 2
      glx-compositor.c
  4. 2
      screenshot.c
  5. 12
      wayland-client.c
  6. 2
      wayland-client.h
  7. 15
      wayland.c
  8. 2
      wayland.h
  9. 4
      window.c

@ -1042,7 +1042,7 @@ int main(int argc, char *argv[])
wl_display_set_compositor(display, &ec->base);
if (wl_display_add_socket(display, socket_name)) {
if (wl_display_add_socket(display, socket_name, sizeof socket_name)) {
fprintf(stderr, "failed to add socket: %m\n");
exit(EXIT_FAILURE);
}

@ -149,7 +149,7 @@ int main(int argc, char *argv[])
loop = g_main_loop_new(NULL, FALSE);
display = wl_display_create(socket_name);
display = wl_display_create(socket_name, sizeof socket_name);
if (display == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return -1;

@ -369,7 +369,7 @@ int main(int argc, char *argv[])
wl_display_set_compositor(display, &gc->base);
if (wl_display_add_socket(display, socket_name)) {
if (wl_display_add_socket(display, socket_name, sizeof socket_name)) {
fprintf(stderr, "failed to add socket: %m\n");
exit(EXIT_FAILURE);
}

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
GSource *source;
struct screenshooter *s;
display = wl_display_create(socket_name);
display = wl_display_create(socket_name, sizeof socket_name);
if (display == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return -1;

@ -83,11 +83,11 @@ connection_update(struct wl_connection *connection,
}
WL_EXPORT struct wl_display *
wl_display_create(const char *address)
wl_display_create(const char *name, size_t name_size)
{
struct wl_display *display;
struct wl_global *global;
struct sockaddr_un name;
struct sockaddr_un addr;
socklen_t size;
char buffer[256];
uint32_t id, length, count, i;
@ -103,12 +103,12 @@ wl_display_create(const char *address)
return NULL;
}
name.sun_family = AF_LOCAL;
memcpy(name.sun_path, address, strlen(address + 1) + 2);
addr.sun_family = AF_LOCAL;
memcpy(addr.sun_path, name, name_size);
size = offsetof (struct sockaddr_un, sun_path) + sizeof socket_name;
size = offsetof (struct sockaddr_un, sun_path) + name_size;
if (connect(display->fd, (struct sockaddr *) &name, size) < 0) {
if (connect(display->fd, (struct sockaddr *) &addr, size) < 0) {
close(display->fd);
free(display);
return NULL;

@ -38,7 +38,7 @@ struct wl_surface;
typedef int (*wl_display_update_func_t)(uint32_t mask, void *data);
struct wl_display *wl_display_create(const char *address);
struct wl_display *wl_display_create(const char *name, size_t name_size);
void wl_display_destroy(struct wl_display *display);
int wl_display_get_fd(struct wl_display *display,
wl_display_update_func_t update, void *data);

@ -90,7 +90,7 @@ struct wl_object_ref {
struct wl_object *object;
struct wl_list link;
};
static void
wl_surface_destroy(struct wl_client *client,
struct wl_surface *surface)
@ -762,9 +762,10 @@ socket_data(int fd, uint32_t mask, void *data)
}
WL_EXPORT int
wl_display_add_socket(struct wl_display *display, const char *socket_name)
wl_display_add_socket(struct wl_display *display,
const char *name, size_t name_size)
{
struct sockaddr_un name;
struct sockaddr_un addr;
int sock;
socklen_t size;
@ -772,11 +773,11 @@ wl_display_add_socket(struct wl_display *display, const char *socket_name)
if (sock < 0)
return -1;
name.sun_family = AF_LOCAL;
memcpy(name.sun_path, socket_name, sizeof socket_name);
addr.sun_family = AF_LOCAL;
memcpy(addr.sun_path, name, name_size);
size = offsetof (struct sockaddr_un, sun_path) + sizeof socket_name;
if (bind(sock, (struct sockaddr *) &name, size) < 0)
size = offsetof (struct sockaddr_un, sun_path) + name_size;
if (bind(sock, (struct sockaddr *) &addr, size) < 0)
return -1;
if (listen(sock, 1) < 0)

@ -119,7 +119,7 @@ wl_input_device_create(struct wl_display *display, const char *path);
struct wl_display *wl_display_create(void);
struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
int wl_display_add_socket(struct wl_display *display, const char *socket_name);
int wl_display_add_socket(struct wl_display *display, const char *name, size_t name_size);
void wl_display_run(struct wl_display *display);
void

@ -270,7 +270,7 @@ event_handler(struct wl_display *display,
buffer->name, buffer->stride,
0, 0, buffer->width, buffer->height);
wl_display_commit(window->display, 0);
window->gears_angle += 1;
window->gears_angle += 1;
} else if (object == 1) {
fprintf(stderr, "unexpected event from display: %d\n",
@ -418,7 +418,7 @@ int main(int argc, char *argv[])
return -1;
}
display = wl_display_create(socket_name);
display = wl_display_create(socket_name, sizeof socket_name);
if (display == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return -1;

Loading…
Cancel
Save