Bug 110847 - occlusion-query.c:190:45: error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
Summary: occlusion-query.c:190:45: error: format specifies type 'unsigned long' but th...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Mark Janes
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords: bisected, regression
Depends on:
Blocks:
 
Reported: 2019-06-06 02:20 UTC by Vinson Lee
Modified: 2019-06-07 00:13 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vinson Lee 2019-06-06 02:20:36 UTC
../src/gallium/tests/graw/occlusion-query.c:190:45: error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
   printf("result1 = %lu  result2 = %lu\n", res1.u64, res2.u64);
                     ~~~                    ^~~~~~~~
                     %llu


commit c9c1e26106478258d8a91fe8fc5c69d8c3fa5206
Author: Mark Janes <mark.a.janes@intel.com>
Date:   Mon Jun 3 16:59:45 2019 -0700

    mesa: prevent common string formatting security issues
    
    Adds a compile-time error for obvious security issues like:
    
      printf(string_var);
    
    The proposed flag is more tolerant than -Wformat-nonliteral.
    Specifically, it tolerates common mesa formatting like:
    
      static const char *shader_template = "really long string %d";
      printf(shader_template, uniform_number);
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110833
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Comment 1 Mark Janes 2019-06-06 05:53:17 UTC
Vinson: I don't know how to reproduce this build error, but I think this patch should fix it:

https://gitlab.freedesktop.org/majanes/mesa/commit/c421d1533f86c5bcd18974164c4e8bf2457e7b96

Can you test the patch and let me know if there are any other printf security issues in your build configuration?
Comment 2 Mark Janes 2019-06-06 06:01:07 UTC
Oops, I guess it needs an include also:

  https://gitlab.freedesktop.org/majanes/mesa/commit/97e056faf38ff65274dd91e2a1d29ae7859c1c51
Comment 3 Emil Velikov 2019-06-06 10:06:56 UTC
(In reply to Mark Janes from comment #2)
> Oops, I guess it needs an include also:
> 
>  
> https://gitlab.freedesktop.org/majanes/mesa/commit/
> 97e056faf38ff65274dd91e2a1d29ae7859c1c51


Patch looks spot-on. Feel free to add my r-b when sending it for inclusion.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Comment 4 Mark Janes 2019-06-07 00:13:47 UTC
Fixed by:

04dac6975234d3b4e5da6aa61e6b787cb576f0e6
Author:     Mark Janes <mark.a.janes@intel.com>

tests/graw: use C99 print conversion specifier for 32 bit builds

Fixes formatting errors for 32 bit compilations, eg:

  error: format specifies type 'unsigned long' but the argument has
  type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
  printf("result1 = %lu result2 = %lu\n", res1.u64, res2.u64);

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.