[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Workaround in 0.6.0


On Thursday 23 August 2012 06:59:43 you wrote:
> Hello,

Hi,

> Wanted to point out the following to the LibSSH group.
> 
> My colleague and I were able to successfully build LibSSH 0.6.0 with a few
> adjustments to the build project.  However, when we attempted to utilize
> the library, we were receiving errors on attempts to authorize with a
> private key.  After much digging around and debugging, we were able to find
> out that the following conditionals were failing:
> 
> ssh_pki_import_privkey_file
> 
>     if (size != sb.st_size) {
> 
> ssh_pki_import_pubkey_file
> 
>     if (size != sb.st_size) {
> 
> We found that the difference was only one byte in length.  After some
> research, we realized that the newline in our private key file was being
> counted as 2 bytes (\r\n) in the following function:
> 
>     rc = stat(filename, &sb);
> 
> However, the following:
> 
>     size = fread(key_buf, 1, sb.st_size, file);
> 
> Was counting the newline as one byte.  In order to solve this issue, we
> simply opened the file with the "binary" option included:
> 
>     file = fopen(filename, "rb");

b is a mode from the windows function?

I don't see it in the linux manpage but adding it doesn't result in an error. 
I think we're fine adding it.


	-- andreas

-- 
Andreas Schneider                   GPG-ID: F33E3FC6
www.cryptomilk.org                asn@xxxxxxxxxxxxxx


References:
Workaround in 0.6.0Jonathan Walker <jwalker@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org