autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] lib/autoconf/c.m4: fix NULL pointer dereference in _AC_LANG_IO_P


From: Nicolas Iooss
Subject: [PATCH] lib/autoconf/c.m4: fix NULL pointer dereference in _AC_LANG_IO_PROGRAM
Date: Mon, 28 Jun 2021 14:13:25 +0200

The following program crashes (with a segmentation fault) when fopen
fails:

    #include <stdio.h>
    int main () {
        FILE *f = fopen ("conftest.out", "w");
        return ferror (f) || fclose (f) != 0;
    }

This is due to ferror dereferencing a NULL pointer (using GNU C Library
2.33).

* lib/autoconf/c.m4: return an error when f is NULL.
---
 lib/autoconf/c.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 9f881f0bc10c..0d9efa62d450 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -114,7 +114,7 @@ $2
 m4_define([_AC_LANG_IO_PROGRAM(C)],
 [AC_LANG_PROGRAM([@%:@include <stdio.h>],
 [FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
+ return !f || ferror (f) || fclose (f) != 0;
 ])])
 
 
-- 
2.30.2


-- 

Les informations contenues dans ce message électronique ainsi que celles 
contenues dans les documents attachés sont strictement confidentielles et 
sont destinées à l'usage exclusif du (des) destinataire(s) nommé(s).
Toute 
divulgation, distribution ou reproduction, même partielle, en est 
strictement interdite sauf autorisation écrite et expresse de l'émetteur.
Si vous recevez ce message par erreur, veuillez le notifier immédiatement à 
son émetteur par retour, et le détruire ainsi que tous les documents qui y 
sont attachés.


The information contained in this email and in any 
document enclosed is strictly confidential and is intended solely for the 
use of the individual or entity to which it is addressed.
Partial or total 
disclosure, distribution or reproduction of its contents is strictly 
prohibited unless expressly approved in writing by the sender.
If you have 
received this communication in error, please notify us immediately by 
responding to this email, and then delete the message and its attached 
files from your system.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]