Menu

#4 Failed to compile when -Werror=format-security

v1.0 (example)
closed
None
5
2015-06-09
2015-06-01
No

When -Werror=format-security, the compile failed with :

ORACERES.cpp: In function 'void translate_race_adjective(char*)':
ORACERES.cpp:543:52: error: format not a string literal and no format arguments [-Werror=format-security]
   snprintf( adjective, RaceInfo::ADJECTIVE_LEN+1, pgettext("Race Adjective", "Norman") );
                                                ^
ORACERES.cpp:543:52: error: format not a string literal and no format arguments [-Werror=format-security]
ORACERES.cpp:548:52: error: format not a string literal and no format arguments [-Werror=format-security]
   snprintf( adjective, RaceInfo::ADJECTIVE_LEN+1, pgettext("Race Adjective", "Mayan") );
                                                ^

....

As these string are not suppose to have format specifiers,
we can use strncpy instead.

The patch to fix this bug is attached.

1 Attachments

Discussion

  • Jesse Allen

    Jesse Allen - 2015-06-09

    Committed. Thanks.

     
  • Jesse Allen

    Jesse Allen - 2015-06-09
    • status: open --> closed
    • assigned_to: Jesse Allen
     

Log in to post a comment.

MongoDB Logo MongoDB