fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include<stdint.h>
  5.  
  6. static uint8_t *elmf_license_get_string(const uint8_t *cert, uint32_t cert_len, const uint8_t *jwt_lic, uint32_t licence_len)
  7. {
  8. if (!cert || !jwt_lic)
  9. return NULL;
  10.  
  11. size_t string_size = licence_len + cert_len + strlen("-----BEGIN LICENSE-----\n") +
  12. strlen("\n-----END LICENSE-----\n");
  13.  
  14. uint8_t *temp = (uint8_t *)malloc(string_size + 1);
  15. if (!temp)
  16. return NULL;
  17.  
  18. strncpy(temp, cert, cert_len);
  19.  
  20. strcat(temp, "-----BEGIN LICENSE-----\n");
  21.  
  22. strncat(temp, jwt_lic, licence_len);
  23.  
  24. strcat(temp, "\n-----END LICENSE-----\n");
  25.  
  26. temp[string_size] = '\0';
  27.  
  28. return temp;
  29. }
  30.  
  31. int main()
  32. {
  33. char * cert = "cert";
  34. char * jwt = "jwt";
  35.  
  36. char * s = elmf_license_get_string(cert, sizeof(cert), jwt, sizeof(jwt));
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty