You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/12/15 22:18:01 UTC

[GitHub] [trafficserver] maskit opened a new pull request, #9256: Use snprintf instead of sprintf

maskit opened a new pull request, #9256:
URL: https://github.com/apache/trafficserver/pull/9256

   This is a following work of #9189. Not complete, but it makes my build happy.


-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] maskit merged pull request #9256: Use snprintf instead of sprintf

Posted by GitBox <gi...@apache.org>.
maskit merged PR #9256:
URL: https://github.com/apache/trafficserver/pull/9256


-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] maskit commented on a diff in pull request #9256: Use snprintf instead of sprintf

Posted by GitBox <gi...@apache.org>.
maskit commented on code in PR #9256:
URL: https://github.com/apache/trafficserver/pull/9256#discussion_r1050414186


##########
example/plugins/c-api/secure_link/secure_link.c:
##########
@@ -125,7 +125,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
   EVP_MD_CTX_destroy(ctx);
 #endif
   for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
-    sprintf(&hash[i * 2], "%02x", md[i]);
+    snprintf(&hash[i * 2], 32, "%02x", md[i]);

Review Comment:
   It was wrong in either way. Fixed.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] maskit commented on a diff in pull request #9256: Use snprintf instead of sprintf

Posted by GitBox <gi...@apache.org>.
maskit commented on code in PR #9256:
URL: https://github.com/apache/trafficserver/pull/9256#discussion_r1050383384


##########
example/plugins/c-api/secure_link/secure_link.c:
##########
@@ -125,7 +125,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
   EVP_MD_CTX_destroy(ctx);
 #endif
   for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
-    sprintf(&hash[i * 2], "%02x", md[i]);
+    snprintf(&hash[i * 2], 32, "%02x", md[i]);

Review Comment:
   I don't understand this one. Do we have another `hash`? I only find `char hash[32]`.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] ywkaras commented on a diff in pull request #9256: Use snprintf instead of sprintf

Posted by GitBox <gi...@apache.org>.
ywkaras commented on code in PR #9256:
URL: https://github.com/apache/trafficserver/pull/9256#discussion_r1050254275


##########
example/plugins/c-api/denylist_1/denylist_1.c:
##########
@@ -179,7 +179,7 @@ read_denylist(TSCont contp)
   char denylist_file[1024];
   TSFile file;
 
-  sprintf(denylist_file, "%s/denylist.txt", TSPluginDirGet());
+  snprintf(denylist_file, 1024, "%s/denylist.txt", TSPluginDirGet());

Review Comment:
   nitpick:  in this case you could use `sizeof(denylist_file)` so the size only needs to be changed in on place.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficserver] ywkaras commented on a diff in pull request #9256: Use snprintf instead of sprintf

Posted by GitBox <gi...@apache.org>.
ywkaras commented on code in PR #9256:
URL: https://github.com/apache/trafficserver/pull/9256#discussion_r1050257384


##########
example/plugins/c-api/secure_link/secure_link.c:
##########
@@ -125,7 +125,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
   EVP_MD_CTX_destroy(ctx);
 #endif
   for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
-    sprintf(&hash[i * 2], "%02x", md[i]);
+    snprintf(&hash[i * 2], 32, "%02x", md[i]);

Review Comment:
   ```
   wkaras /tmp/x
   O$ cat x.cc
   char x[3][32];
   
   void f(int i)
   {
     static_assert(sizeof(x[i]) == 32);
   }
   wkaras /tmp/x
   O$ gcc -c -pedantic -Wall -Wextra -std=c++17 x.cc
   wkaras /tmp/x
   O$
   ```
   Strongly recommend using `sizeof(hash[i * 2])` instead of `32`.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org