Skip Menu |

This queue is for tickets about the Crypt-U2F-Server CPAN distribution.

Report information
The Basics
Id: 129341
Status: resolved
Priority: 0/
Queue: Crypt-U2F-Server

People
Owner: Nobody in particular
Requestors: NEWELLC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.43
Fixed in: 0.44



Subject: Module segfaults if u2fclib_verifyRegistration returns 0 to indicate an error occurred
Module segfaults if u2fclib_verifyRegistration returns 0 to indicate an error occurred. The xs code tries to do a strncpy on it assuming it never returns 0. Program terminated with signal SIGSEGV, Segmentation fault. #0 __strncpy_avx2 () at ../sysdeps/x86_64/multiarch/strcpy-avx2.S:301 301 ../sysdeps/x86_64/multiarch/strcpy-avx2.S: No such file or directory. (gdb) bt #0 __strncpy_avx2 () at ../sysdeps/x86_64/multiarch/strcpy-avx2.S:301 #1 0x00007fa4545f36c8 in strncpy (__len=10000, __src=<optimised out>, __dest=0x7ffe850cfe80 "(\377\f\205\376\177") at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106 #2 XS_Crypt__U2F__Server_u2fclib_verifyRegistration (cv=<optimised out>) at U2F.xs:79 #3 0x00005623c2ebde78 in Perl_pp_entersub () #4 0x00005623c2eb5f63 in Perl_runops_standard () #5 0x00005623c2e42171 in perl_run () #6 0x00005623c2e1d4ef in main ()
This patch appears to fix the function so it returns nothing which makes Crypt::U2F::Server::Simple work as expected and set the last error so lastError works as expected.
Subject: fix.patch
diff -Naur Crypt-U2F-Server-0.43/U2F.xs /home/colin/.cpanm/work/1556358510.4575/Crypt-U2F-Server-0.43/U2F.xs --- Crypt-U2F-Server-0.43/U2F.xs 2018-04-05 09:55:28.000000000 +0100 +++ /home/colin/.cpanm/work/1556358510.4575/Crypt-U2F-Server-0.43/U2F.xs 2019-04-27 19:29:31.343363023 +0100 @@ -75,7 +75,12 @@ INIT: char* pk[65]; char kh[1000]; + char *result; PPCODE: - strncpy(kh,u2fclib_verifyRegistration(ctx, buf, pk),1000); + result = u2fclib_verifyRegistration(ctx, buf, pk); + if(!result) { + XSRETURN_UNDEF; + } + strncpy(kh,result,1000); XPUSHs(sv_2mortal(newSVpvn(pk,65))); XPUSHs(sv_2mortal(newSVpvn(kh,strlen(kh))));
Le Sam 27 Avr 2019 14:33:03, NEWELLC a écrit : Show quoted text
> This patch appears to fix the function so it returns nothing which > makes Crypt::U2F::Server::Simple work as expected and set the last > error so lastError works as expected.
Hello, looks good to me. I'll test and update soon. Many thanks !
Le Dim 28 Avr 2019 09:25:02, GUIMARD a écrit : Show quoted text
> Le Sam 27 Avr 2019 14:33:03, NEWELLC a écrit :
> > This patch appears to fix the function so it returns nothing which > > makes Crypt::U2F::Server::Simple work as expected and set the last > > error so lastError works as expected.
> > Hello, > > looks good to me. I'll test and update soon. Many thanks !
Fixed in 0.44, test added