Hi On Tue, Jun 25, 2019 at 3:49 PM Gert Doering <g...@greenie.muc.de> wrote: > > Hi, > > On Tue, Jun 25, 2019 at 10:34:01PM +0300, Lev Stipakov wrote: > > ack_message_t ack; > > struct gc_arena gc = gc_new(); > > > > - if (!send_msg_iservice(pipe, rt, size, &ack, "ROUTE")) > > + if (!send_msg_iservice(pipe, rt, size, &ack, sizeof(ack), "ROUTE")) > > I do not like this. Please find another way to send the request message > "with length" than to add an extra parameter to every single caller of > send_msg_iservice().
Gert beat me to it :) Anyway, me too! The way interactive service structures are coded should not require this at all, does it? The size and message type are already in the header, so why do we need to pass it? The result here is a new kind of ack message with a different size and type and that could be checked by accessing the header element. Unless I'm missing something. > > + HANDLE local_handle = CreateFileA(open_tun->device_path, GENERIC_READ | > GENERIC_WRITE, 0, 0, > + OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | > FILE_FLAG_OVERLAPPED, 0); > + > + if (local_handle == INVALID_HANDLE_VALUE) > + { > + WCHAR *device_path_wchar = NULL; > + int size = sizeof(open_tun->device_path); > + err = GetLastError(); > + > + device_path_wchar = malloc(size * sizeof(WCHAR)); > + if (device_path_wchar) > + { > + MultiByteToWideChar(CP_UTF8, 0, open_tun->device_path, size, > device_path_wchar, size); > + device_path_wchar[size - 1] = 0; > + } > + MsgToEventLog(M_SYSERR, TEXT("Error opening tun device (%s)"), > device_path_wchar); > + free(device_path_wchar); > + return err; > + } > Also this one -- I think we should just use the wide version of CreateFile -- all strings in OpenVPN.exe are supposed to be in utf8, so convert to widechar and call CreateFileW. Selva _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel