GNU bug report logs - #73444
30.0.50; mingw-w64: Emacs uses CRT's `read` when _FORTIFY_SOURCE > 0

Previous Next

Package: emacs;

Reported by: Óscar Fuentes <ofv <at> wanadoo.es>

Date: Mon, 23 Sep 2024 22:16:02 UTC

Severity: normal

Merged with 63752

Found in versions 28.2, 30.0.50

Done: Óscar Fuentes <ofv <at> wanadoo.es>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: 73444 <at> debbugs.gnu.org
Subject: bug#73444: 30.0.50; mingw-w64: Emacs uses CRT's `read` when _FORTIFY_SOURCE > 0
Date: Tue, 24 Sep 2024 16:27:39 +0300
> From: Óscar Fuentes <ofv <at> wanadoo.es>
> Cc: 73444 <at> debbugs.gnu.org
> Date: Tue, 24 Sep 2024 14:55:56 +0200
> 
> I tested that Emacs/MinGW64 + _FORTIFY_SOURCE works with the
> 
> #define read dummy_read
> 
> hack. Once we put the prototype for sys_read on ms-w32.h, maybe there is
> no need to put a conditional on _FORTIFY_SOURCE as well. I can check
> that.

Yes, I'd like to avoid the _FORTIFY_SOURCE conditional, so that this
code is always used.

> So, ok to install the workaround? On which branch?

On master, please.

> @@ -257,7 +257,7 @@ extern void w32_reset_stack_overflow_guard (void);
>  #define link    sys_link
>  #define localtime sys_localtime
>  #undef read
> -#define read    sys_read
> +#define read    unwanted_read // Override the CRT read, see #73444
>  #define rename  sys_rename
>  #define rmdir   sys_rmdir
>  #define select  sys_select
> @@ -380,6 +380,11 @@ extern struct tm *localtime_r (time_t const * restrict, struct tm * restrict);
>  #define fileno	  _fileno
>  #endif
>  
> +// Here we override CRT read with our own, see #73444
> +#undef read
> +#define read    sys_read
> +int sys_read (int, char *, unsigned int);
> +
>  /* Defines that we need that aren't in the standard signal.h.  */
>  #define SIGHUP  1               /* Hang up */
>  #define SIGQUIT 3               /* Quit process */

But please don't use "//" as comment style, and please don't forget
mentioning the bug number in the commit log message.

Thanks.




This bug report was last modified 312 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.