[Ada] Warn for bidirectional characters

Pierre-Marie de Rodat derodat@adacore.com
Wed Nov 10 08:58:50 GMT 2021


Bidirectional characters can cause security vulnerabilities, as
explained in the paper mentioned in a comment in this patch.
Therefore, we warn if such characters appear in string_literals,
character_literals, or comments.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* scng.adb (Check_Bidi): New procedure to give warning. Note
	that this is called only for non-ASCII characters, so should not
	be an efficiency issue.
	(Slit): Call Check_Bidi for wide characters in string_literals.
	(Minus_Case): Call Check_Bidi for wide characters in comments.
	(Char_Literal_Case): Call Check_Bidi for wide characters in
	character_literals.  Move Accumulate_Checksum down, because
	otherwise, if Err is True, the Code is uninitialized.
	* errout.ads: Make the obsolete nature of "Insertion character
	?" more prominent; one should not have to read several
	paragraphs before finding out that it's obsolete.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 5128 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211110/915501c3/attachment.bin>


More information about the Gcc-patches mailing list