You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

11 years ago
  1. diff --git a/src/main-ctl-unix.c b/src/main-ctl-unix.c
  2. index b4da5eb..90d604f 100644
  3. --- a/src/main-ctl-unix.c
  4. +++ b/src/main-ctl-unix.c
  5. @@ -629,7 +629,7 @@ static void ctl_handle_commands(main_server_st * s)
  6. }
  7. goto cleanup;
  8. }
  9. - length = (buffer[2] << 8) | buffer[1];
  10. + memcpy(&length, &buffer[1], 2);
  11. buffer_size = ret - 3;
  12. if (length != buffer_size) {
  13. diff --git a/src/occtl-unix.c b/src/occtl-unix.c
  14. index 183825d..0c1b3e1 100644
  15. --- a/src/occtl-unix.c
  16. +++ b/src/occtl-unix.c
  17. @@ -83,15 +83,14 @@ int send_cmd(struct unix_ctx *ctx, unsigned cmd, const void *data,
  18. struct iovec iov[2];
  19. unsigned iov_len = 1;
  20. int e, ret;
  21. - unsigned length = 0;
  22. + uint16_t length = 0;
  23. void *packed = NULL;
  24. if (get_size)
  25. length = get_size(data);
  26. header[0] = cmd;
  27. - header[1] = length;
  28. - header[2] = length >> 8;
  29. + memcpy(&header[1], &length, 2);
  30. iov[0].iov_base = header;
  31. iov[0].iov_len = 3;
  32. @@ -145,7 +144,7 @@ int send_cmd(struct unix_ctx *ctx, unsigned cmd, const void *data,
  33. goto fail;
  34. }
  35. - length = (header[2] << 8) | header[1];
  36. + memcpy(&length, &header[1], 2);
  37. rep->data_size = length;
  38. rep->data = talloc_size(ctx, length);
  39. diff --git a/src/sec-mod.c b/src/sec-mod.c
  40. index 15ee32a..c3d4bad 100644
  41. --- a/src/sec-mod.c
  42. +++ b/src/sec-mod.c
  43. @@ -354,6 +354,7 @@ void sec_mod_server(void *main_pool, struct cfg_st *config, const char *socket_f
  44. unsigned cmd, length;
  45. unsigned i, buffer_size;
  46. uint8_t *buffer, *tpool;
  47. + uint16_t l16;
  48. struct pin_st pins;
  49. int sd;
  50. sec_mod_st *sec;
  51. @@ -538,10 +539,11 @@ void sec_mod_server(void *main_pool, struct cfg_st *config, const char *socket_f
  52. }
  53. cmd = buffer[0];
  54. - length = buffer[1] | buffer[2] << 8;
  55. + memcpy(&l16, &buffer[1], 2);
  56. + length = l16;
  57. if (length > buffer_size - 4) {
  58. - seclog(LOG_INFO, "too big message");
  59. + seclog(LOG_INFO, "too big message (%d)", length);
  60. goto cont;
  61. }