mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Avoid truncation or bad formatting in message header
This commit is contained in:
		| @@ -594,11 +594,7 @@ private: | ||||
|         inline void encode_header() | ||||
|         { | ||||
|             char header[header_length + 1] = ""; | ||||
|             int num_chars = std::snprintf(header, header_length + 1, "GS%4d", std::min(static_cast<int>(body_length_), static_cast<int>(max_body_length))); | ||||
|             if ((num_chars <= 0) or (num_chars > header_length)) | ||||
|                 { | ||||
|                     // avoid Wformat-truncation warning | ||||
|                 } | ||||
|             std::snprintf(header, header_length + 1, "GS%4d", std::max(std::min(static_cast<int>(body_length_), static_cast<int>(max_body_length)), 0)); | ||||
|             std::memcpy(data_, header, header_length); | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez