On Sat, Oct 08, 2016 at 16:14 -0400, Gaitan D'Antoni wrote: > > I just built libserialport on Windows 10 and while stepping through the > code I noticed a bug so I created the following patch: > > --- serialport.c 2016-10-08 13:41:23.269484000 -0400 > +++ serialport1.c 2016-10-08 13:43:10.958994300 -0400 > @@ -459,8 +459,8 @@ > char *escaped_port_name; > COMSTAT status; > > - /* Prefix port name with '\\.\' to work with ports above COM9. */ > - if (!(escaped_port_name = malloc(strlen(port->name) + 5))) > + /* Prefix port name with '\\\\.\\' to work with ports above COM9. */ > + if (!(escaped_port_name = malloc(strlen(port->name) + 8))) > RETURN_ERROR(SP_ERR_MEM, "Escaped port name malloc failed"); > sprintf(escaped_port_name, "\\\\.\\%s", port->name);
Can you expand on what's the issue? I cannot see an obvious problem in the original source from looking at the patch. And there is no comment / commit message that comes with your patch, explaining what the problem was and what the consequences might be, or how the changed version has improved. Consider that strlen("\\") == 1, and thus strlen("\\\\.\\") == 4. The first backslash escapes the subsequent one, the resulting string after resolving the escaped sequence is a single backslash (or three backslashes plus a dot in the second term). Also note the different quote characters. The _source code_ uses double quotes, because that's how strings are phrased in the C programming language. The _comment_ uses single quotes, which by convention denote "citations" or strict terms in the verbatim sense. So it's really \\.\ which needs to get prepended (that's a "UNC" style Windows path name). It just happens to get phrased as "\\\\.\\" in the specific programming language. Did I miss something? virtually yours Gerhard Sittig -- If you don't understand or are scared by any of the above ask your parents or an adult to help you. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel