2025-07-31 02:48 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001416Spring engineGeneralpublic2009-05-26 19:50
ReporterAdamW 
Assigned Totvo 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.79.0.2 
Target VersionFixed in Version 
Summary0001416: [patch] "format not a string literal and no format arguments" in spring_0.79.0.2/rts/Rendering/glFont.cpp:559
DescriptionI am the maintainer of Mandriva's packages for spring. Mandriva buildsystem sets "format not a string literal and no format arguments" to be an error rather than a warning, as it always indicates a coding error that should be fixed, and is a problem that can frequently cause security issues. See Mandriva's write-up of the issue:

http://wiki.mandriva.com/en/Development/Packaging/Problems#format_not_a_string_literal_and_no_format_arguments

Trying to update the package to 0.79.0.2, I am hitting such an error in spring_0.79.0.2/rts/Rendering/glFont.cpp:559 :

/home/adamw/rpm/BUILD/spring_0.79.0.2/rts/Rendering/glFont.cpp: In static member function 'static CglFont* CglFont::LoadFont(const std::string&, int, int, float, int, int)':
/home/adamw/rpm/BUILD/spring_0.79.0.2/rts/Rendering/glFont.cpp:559: error: format not a string literal and no format arguments

unfortunately, I'm not a hacker and this code in question doesn't exactly fit the examples on the Mandriva page, so I cannot fix it myself and provide a patch. Thanks a lot for looking at this issue.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon glFont.patch (502 bytes) 2009-05-26 19:00 -
    diff --git rts/Rendering/glFont.cpp rts/Rendering/glFont.cpp
    index d341a64..3b97418 100644
    --- rts/Rendering/glFont.cpp
    +++ rts/Rendering/glFont.cpp
    @@ -556,7 +556,7 @@ CglFont* CglFont::LoadFont(const std::string& fontFile, int size, int outlinewid
     		logOutput.Print("FONT-ERROR: Couldn't create GlyphAtlas! (try to reduce reduce font size/outlinewidth)");
     		return NULL;
     	} catch (content_error& e) {
    -		logOutput.Print(e.what());
    +		logOutput.Print(std::string(e.what()));
     		return NULL;
     	}
     }
    
    patch file icon glFont.patch (502 bytes) 2009-05-26 19:00 +

-Relationships
+Relationships

-Notes

~0003487

jasonobrien (reporter)

This is a problem with our function overloading, we have two methods one that takes printf-style args and another that simply takes a string. The printf style one prevents promotion of c-stings to std::string, even if we pass no format arguments. As far as solutions go, renaming the function to PrintFormat would do. For now, submitted a patch which forces the correct function choice.

~0003490

tvo (reporter)

committed, thanks.
+Notes

-Issue History
Date Modified Username Field Change
2009-05-26 18:47 AdamW New Issue
2009-05-26 19:00 jasonobrien Note Added: 0003487
2009-05-26 19:00 jasonobrien File Added: glFont.patch
2009-05-26 19:44 tvo Summary "format not a string literal and no format arguments" in spring_0.79.0.2/rts/Rendering/glFont.cpp:559 => [patch] "format not a string literal and no format arguments" in spring_0.79.0.2/rts/Rendering/glFont.cpp:559
2009-05-26 19:44 tvo Status new => assigned
2009-05-26 19:44 tvo Assigned To => tvo
2009-05-26 19:50 tvo Note Added: 0003490
2009-05-26 19:50 tvo Status assigned => resolved
2009-05-26 19:50 tvo Fixed in Version => master
2009-05-26 19:50 tvo Resolution open => fixed
+Issue History