hplip 3.22.6 cannot be compiled when -Werror=format-security is used for compilation

Bug #1982185 reported by zdohnal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned

Bug Description

Hi all,

the new version 3.22.6 fails to build from source due compilation errors:

8565 protocol/hp_ipp.c:113:9: error: format not a string literal and no format arguments [-Werror=format-security]
8566 113 | snprintf( info,sizeof(info), name );
8567 | ^~~~~~~~
8576 protocol/hp_ipp.c:514:19: error: format not a string literal and no format arguments [-Werror=format-security]
8577 514 | snprintf(t_printer->name, sizeof(t_printer->name),ippGetString(attr, 0, NULL) );
8578 | ^~~~~~~~
8579 protocol/hp_ipp.c:518:19: error: format not a string literal and no format arguments [-Werror=format-security]
8580 518 | snprintf(t_printer->device_uri,sizeof(t_printer->device_uri), ippGetString(attr, 0, NULL) );
8581 | ^~~~~~~~
8582 protocol/hp_ipp.c:522:19: error: format not a string literal and no format arguments [-Werror=format-security]
8583 522 | snprintf(t_printer->printer_uri,sizeof(t_printer->printer_uri), ippGetString(attr, 0, NULL) );
8584 | ^~~~~~~~
8585 protocol/hp_ipp.c:526:19: error: format not a string literal and no format arguments [-Werror=format-security]
8586 526 | snprintf(t_printer->info,sizeof(t_printer->info), ippGetString(attr, 0, NULL) );
8587 | ^~~~~~~~
8588 protocol/hp_ipp.c:530:19: error: format not a string literal and no format arguments [-Werror=format-security]
8589 530 | snprintf(t_printer->location,sizeof(t_printer->location),ippGetString(attr, 0, NULL) );
8590 | ^~~~~~~~
8591 protocol/hp_ipp.c:534:19: error: format not a string literal and no format arguments [-Werror=format-security]
8592 534 | snprintf(t_printer->make_model,sizeof(t_printer->make_model),ippGetString(attr, 0, NULL) );
8593 | ^~~~~~~~

If an input variable is passed into snprintf(), the function expects an argument defining the format how is the string printed into output variable.

The patch is attached, it contains one more fix (we cannot snprintf into NULL variable...)

Would you mind adding it into the project?

Revision history for this message
zdohnal (zdohnal) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.