Browse Source

Be really sneaky and use GNU ld special stuff so that whenever folks
use the unsafe gets, they will get a warning from the linker. muahahaha.
This method will soon be applied to fork() w/o an mmu etc...
-Erik

Eric Andersen 23 years ago
parent
commit
70b504a538
2 changed files with 12 additions and 0 deletions
  1. 11 0
      include/features.h
  2. 1 0
      libc/stdio/stdio.c

+ 11 - 0
include/features.h

@@ -90,5 +90,16 @@
 #include <bits/uClibc_config.h>
 #undef __need_uClibc_config_h
 
+
+#if 1	/* This only works with GNU ld, but that is what we use 'round these parts */
+#define link_warning(symbol, msg) \
+asm (".section "  ".gnu.warning." #symbol  "\n\t.previous");  \
+static const char __evoke_link_warning_##symbol[]     \
+__attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
+#else
+# define link_warning(symbol, msg)
+#endif
+
+
 #endif
 

+ 1 - 0
libc/stdio/stdio.c

@@ -314,6 +314,7 @@ char *fgets(char *s, int count, FILE *fp)
 #endif
 
 #ifdef L_gets
+link_warning (gets, "the `gets' function is dangerous and should not be used.")
 char *gets(char *str) /* This is an UNSAFE function! */
 {
 	/*