google / google-authenticator-libpam

Apache License 2.0
1.76k stars 281 forks source link

Failure to allocate memory after 1.07 update #146

Closed driesmp closed 4 years ago

driesmp commented 4 years ago

Dec 31 10:51:38 vados kernel: Dec 31 10:51:38 vados sshd(pam_google_authenticator)[94634]: Short (-1) mem allocation failed Dec 31 10:51:38 vados kernel: Dec 31 10:51:38 vados sshd(pam_google_authenticator)[94634]: Out of memory

Hi, I'm maintaining the port of FreeBSD, and after updating it to 1.07 something changed in the behavior. Each time someone logs in and pam_google_authenticator is up for its authentication I get the error you see above. This would also prohibit me from logging in entirely.

I'm not out of memory at all. So seems like a bug.

ThomasHabets commented 4 years ago

Indeed negative 1 bytes is a short allocation.

ThomasHabets commented 4 years ago

Oh, I see it. It's comparing a size_t to see if it's less than zero. Since commit becf7abfe5c884dcc8d8a9a2db48a12912cde410 Doh.

ThomasHabets commented 4 years ago

Single-character fix: ssize_t instead of size_t on line 189. Or https://github.com/google/google-authenticator-libpam/commit/1927ade9f6172783b4a14df1a62c05bf336096aa.

Could you confirm that this fixes it, and I'll tag a 1.08?

driesmp commented 4 years ago

Just tested your patch, works fine. Thanks for the quick response!

ThomasHabets commented 4 years ago

1.08 tagged, with only diff from 1.07 being this fix.

stefansedich commented 4 years ago

Just got bit by after upgrading to Alpine 3.11 for our OpenVPN instances, for anyone suffering the same installing from the edge/community repo will give you 1.08:

echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk add --update google-authenticator@edge