patch-src_emu_webengine_c 1.1 KB

12345678910111213141516171819202122
  1. $OpenBSD: patch-src_emu_webengine_c,v 1.1 2017/04/24 07:52:21 jca Exp $
  2. --- src/emu/webengine.c.orig Mon Apr 24 04:35:18 2017
  3. +++ src/emu/webengine.c Mon Apr 24 04:36:04 2017
  4. @@ -321,7 +321,7 @@ int web_engine::begin_request_handler(struct mg_connec
  5. else if (!strncmp(conn->uri, "/keyupload",8))
  6. {
  7. char *upload_data;
  8. - int data_length, ofs = 0;
  9. + int data_length = 0, ofs = 0;
  10. char var_name[100], file_name[255];
  11. while ((ofs = mg_parse_multipart(conn->content + ofs, conn->content_len - ofs, var_name, sizeof(var_name), file_name, sizeof(file_name), (const char **)&upload_data, &data_length)) > 0) {
  12. mg_printf_data(conn, "File: %s, size: %d bytes", file_name, data_length);
  13. @@ -330,7 +330,7 @@ int web_engine::begin_request_handler(struct mg_connec
  14. // That upload_data contains more than we need. It also has the headers.
  15. // We'll need to strip it down to just what we want.
  16. - if ((&data_length > 0) && (sizeof(file_name) > 0))
  17. + if ((data_length > 0) && (strlen(file_name) > 0))
  18. {
  19. // MSVC doesn't yet support variable-length arrays, so chop the string the old-fashioned way
  20. upload_data[data_length] = '\0';