empiredan commented on PR #2223:
URL: https://github.com/apache/zookeeper/pull/2223#issuecomment-2749996853

   > @empiredan Thank you for your contribution! I checked the refined 
`zoo_sasl_password_callback_t`, I think it is better than what I suggested.
   > 
   > I left a comment about api doc. The rest looks good to me.
   
   Got it! Indeed, over-explaining could cause confusion for users, so 
simplifying the documentation makes sense.  
   
   The `sasl_secret_t` structure does not strictly require the `data` field to 
be null-terminated, but we are keeping it for the following reasons:
   ```c
   typedef struct sasl_secret {
       unsigned long len;
       unsigned char data[1];           /* variable sized */
   } sasl_secret_t;
   ```
   
   1. There may be existing code that directly uses string functions to process 
the `data` field.  
   2. The `unsigned char data[1];` flexible array provides a natural way to 
store the null terminator.  
   3. The previous implementation used `strcpy((char *) x->data, password);` 
for copying, which inherently includes a `\0` at the end. Therefore, it makes 
sense to preserve the null terminator.


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