deiv commented on pull request #2235:
URL: https://github.com/apache/thrift/pull/2235#issuecomment-689636406


   > > we need only path_.size()
   > 
   > so you're saying, this would be correct call?
   > 
   > ```
   > sockaddr_un addr;
   > addr.sun_family = AF_UNIX;
   > addr.sun_path[0] = '\0';
   > addr.sun_path[1] = 'A';
   > addr.sun_path[2] = 'B';
   > addr.sun_path[3] = 'C';
   > 
   > bind(sockfd, &addr, 3);
   > //                  ^ here, 3? not 4?
   > ```
   
   Not, is 4, but when you will do `"\0ABC".size() + 1`, it will gives 5.
   
   > > Maybe a comment could do the job ?
   > 
   > As you can see, there's already one. Is it helpful?
   
   The comment is:
   
   >       // sun_path is not null-terminated in this case and structlen 
determines its length
   
   Yes, is helpful, it's give the correct way to do.
   
   But the code was not the correct, because it uses the variable `len` that is 
the length of the string plus the terminating caracter \0.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to