xiaoxiang781216 commented on code in PR #3601:
URL: https://github.com/apache/nuttx-apps/pull/3601#discussion_r3526135317


##########
examples/udgram/udgram_client.c:
##########
@@ -91,14 +91,10 @@ int main(int argc, FAR char *argv[])
 
       /* Set up the server address */
 
-      addrlen = sizeof(CONFIG_EXAMPLES_UDGRAM_ADDR);
-      if (addrlen > UNIX_PATH_MAX)
-        {
-          addrlen = UNIX_PATH_MAX;
-        }
+      addrlen = strnlen(CONFIG_EXAMPLES_UDGRAM_ADDR, UNIX_PATH_MAX - 1);
 
       server.sun_family = AF_LOCAL;
-      strlcpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen);
+      strlcpy(server.sun_path, CONFIG_EXAMPLES_UDGRAM_ADDR, addrlen + 1);

Review Comment:
   why change? strlcpy could ensure '\0' is terminated at the end of 
server.sun_path



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to