[asan] print the 'unexpected format specifier in printf interceptor' warning just once (came up in https://github.com/google/oss-fuzz/pull/562). Not touching a similar scanf warning -- for some reason it does not fire for me.
llvm-svn: 302064
This commit is contained in:
		
							parent
							
								
									23f314d04f
								
							
						
					
					
						commit
						8c34243a13
					
				| 
						 | 
				
			
			@ -325,8 +325,8 @@ static void scanf_common(void *ctx, int n_inputs, bool allowGnuMalloc,
 | 
			
		|||
      continue;
 | 
			
		||||
    int size = scanf_get_value_size(&dir);
 | 
			
		||||
    if (size == FSS_INVALID) {
 | 
			
		||||
      Report("WARNING: unexpected format specifier in scanf interceptor: "
 | 
			
		||||
        "%.*s\n", dir.end - dir.begin, dir.begin);
 | 
			
		||||
      Report("%s: WARNING: unexpected format specifier in scanf interceptor: ",
 | 
			
		||||
             SanitizerToolName, "%.*s\n", dir.end - dir.begin, dir.begin);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    void *argp = va_arg(aq, void *);
 | 
			
		||||
| 
						 | 
				
			
			@ -520,8 +520,12 @@ static void printf_common(void *ctx, const char *format, va_list aq) {
 | 
			
		|||
      continue;
 | 
			
		||||
    int size = printf_get_value_size(&dir);
 | 
			
		||||
    if (size == FSS_INVALID) {
 | 
			
		||||
      Report("WARNING: unexpected format specifier in printf "
 | 
			
		||||
             "interceptor: %.*s\n", dir.end - dir.begin, dir.begin);
 | 
			
		||||
      static int ReportedOnce;
 | 
			
		||||
      if (!ReportedOnce++)
 | 
			
		||||
        Report(
 | 
			
		||||
            "%s: WARNING: unexpected format specifier in printf "
 | 
			
		||||
            "interceptor: %.*s (reported once per process)\n",
 | 
			
		||||
            SanitizerToolName, dir.end - dir.begin, dir.begin);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    if (dir.convSpecifier == 'n') {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
// RUN: %clang -w -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
 | 
			
		||||
// UNSUPPORTED: lsan
 | 
			
		||||
// UNSUPPORTED: msan
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
int main() {
 | 
			
		||||
  int a;
 | 
			
		||||
  printf("%Q\n", 1);
 | 
			
		||||
  printf("%Q\n", 1);
 | 
			
		||||
  printf("%Q\n", 1);
 | 
			
		||||
}
 | 
			
		||||
// CHECK: unexpected format specifier in printf interceptor: %Q (reported once per process)
 | 
			
		||||
// CHECK-NOT: unexpected format specifier in printf interceptor
 | 
			
		||||
		Loading…
	
		Reference in New Issue