wrong null pointer check

Bug #1794999 reported by Kiss György
258
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pam-python (Ubuntu)
Confirmed
Undecided
Unassigned
Precise
Won't Fix
Undecided
Unassigned
Trusty
New
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Undecided
Unassigned

Bug Description

Building pam-python from source on Ubuntu bionic fails with this error message:

make[2]: Entering directory '/tmp/source_copy/pam-python/src'
gcc -O0 -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror -g -o ctest ctest.c -lpam
CFLAGS="-Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror -I/usr/local/lib/ " ./setup.py build
running build
running build_ext
building 'pam_python' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror -I/usr/local/lib/ -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DLIBPYTHON_SO="libpython2.7.so.1.0" -I/usr/include/python2.7 -c pam_python.c -o build/temp.linux-x86_64-2.7/pam_python.o
pam_python.c: In function 'call_handler':
pam_python.c:2229:19: error: argument 1 null where non-null expected [-Werror=nonnull]
   if (dot != 0 || strcmp(dot, ".py") == 0)
                   ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/security/_pam_macros.h:13:0,
                 from pam_python.c:33:
/usr/include/string.h:136:12: note: in a call to function 'strcmp' declared here
 extern int strcmp (const char *__s1, const char *__s2)
            ^~~~~~
cc1: all warnings being treated as errors
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make[2]: *** [pam_python.so] Error 1
Makefile:9: recipe for target 'pam_python.so' failed
make[2]: Leaving directory '/tmp/source_copy/pam-python/src'
make[1]: *** [lib] Error 2
make: *** [build-arch] Error 2
Makefile:6: recipe for target 'lib' failed
make[1]: Leaving directory '/tmp/source_copy/pam-python'
debian/rules:38: recipe for target 'build-arch' failed
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

The null pointer check condition is wrong in pam_python.c:2229

Tags: patch
Kiss György (w2lkm2n)
information type: Public → Public Security
Revision history for this message
Kiss György (w2lkm2n) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Fix wrong null pointer check" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Eduardo Barretto (ebarretto) wrote :

Thanks for taking the time to report this bug and helping to make Ubuntu better.
I took a look at your patch and I don't think it is the best solution. As far as I can tell, the problem is actually caused because of toolchain (gcc) version in bionic. I've tried to build the same version of pam-python on Xenial and it worked. So changing the logic, like your patch does, will probably break something else during execution or bring up other problems.
Also checking the build of pam-python with gcc8 brings up more errors during build, besides the one you mentioned. So the project needs an update.
Have you tried to contact upstream maintainer?
http://pam-python.sourceforge.net/
It seems like the project is not being developed anymore, so it might be difficult to get an answer, but worth a try.
Let me know if you have problems in contacting upstream maintainer.

Revision history for this message
Eduardo Barretto (ebarretto) wrote :

So I took another look at the patch and the current code and maybe I was too hard in my response.
The current code is wrong as it will still make the string comparison even if dot is null. So the patch fixes this problem and should be proposed to upstream.

As I mentioned the package also has other warnings that make the build fail (because of -Werror) with gcc8, if you also want to get this fixed and send to upstream here is a log file that shows all the failures found so far (if you get them fixed, maybe other errors/warnings might come up):
https://launchpadlibrarian.net/367623423/buildlog_ubuntu-bionic-amd64.pam-python_1.0.6-1_BUILDING.txt.gz

Let me know if you have problems to access the build log.

If upstream doesn't respond we can discuss about shipping the patch with the package.

Revision history for this message
Eduardo Barretto (ebarretto) wrote :

So I've talked to upstream and Russel mentioned that a new version is coming next year.
For more information:
https://sourceforge.net/p/pam-python/tickets/5/

Changed in pam-python (Ubuntu):
status: New → Confirmed
Changed in pam-python (Ubuntu Xenial):
status: New → Fix Released
Changed in pam-python (Ubuntu Bionic):
status: New → Fix Released
no longer affects: pam-python (Ubuntu Focal)
Revision history for this message
Steve Langasek (vorlon) wrote :

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in pam-python (Ubuntu Precise):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.