LedgerHQ / nanos-secure-sdk

Secure (ST31) SDK for Ledger Nano S
Apache License 2.0
96 stars 54 forks source link

snprintf always return 0 #28

Closed shufps closed 1 year ago

shufps commented 3 years ago

Should probably return ulPos.

https://github.com/LedgerHQ/nanos-secure-sdk/blob/e3293938e5988e1ffa05d1f2ba23db431275f21c/src/os_printf.c#L1180

shufps commented 3 years ago

Ah sorry, ulPos also is wrong ... it needs some more changes.

shufps commented 3 years ago

this should work.:

//unsigned int snprintf(unsigned char * str, unsigned int str_size, const char* format, ...)
int snprintf(char * str, size_t str_size, const char * format, ...)
 {
  //........    
    char* op_str = str;
  //........
    return (uint32_t) str - (uint32_t) op_str;
}
xchapron-ledger commented 1 year ago

I have moved your issue to the new SDK https://github.com/LedgerHQ/ledger-secure-sdk/issues/236