openSUSE / libsolv

Library for solving packages and reading repositories
http://en.opensuse.org/openSUSE:Libzypp_satsolver
Other
517 stars 152 forks source link

Unable to find size of unsigned char string returned by solvable_lookup_bin_checksum #537

Closed shivania2 closed 1 year ago

shivania2 commented 1 year ago

I am trying to collect the binary checksum of a package using solvable_lookup_bin_checksum(). But I am not sure how to find the returned unsigned character string length as it contains binary data and it is not NULL terminated(Cannot use tradition string.c function).

Let me know what you suggest how can we calculate the returned unsigned character string length.

Attaching my code snippet i am trying to copy the return string in other unsigned char string, but not able to get correct result because of length issue.


unsigned char *pszTemp = solvable_lookup_bin_checksum(pSolv, SOLVABLE_CHECKSUM, &checksumtype);
size_t pszTemp_size = strlen((const char*)pszTemp) + 1;
unsigned char *pszChecksum= (unsigned char *)calloc(pszTemp_size, sizeof(unsigned char));
memcpy(pszChecksum, pszTemp, pszTemp_size);```
shivania2 commented 1 year ago

Able to resolve issue with predefined SHA-length

mlschroe commented 1 year ago
size = solv_chksum_len(checksumtype);