mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-31 11:17:01 -07:00 
			
		
		
		
	Error gracefully when requested to write a too-large scp image
This prevents a crash when more tracks were recorded than fit in an scp image. When I first encountered a problem doing an 84-track operation, this led to a segfault later on since memory was written past the end of _fileheader, and (I think) stomped on a pointer.
This commit is contained in:
		| @@ -85,6 +85,12 @@ public: | ||||
| 		trackdataWriter.seekToEnd(); | ||||
| 		int strack = strackno(cylinder, head); | ||||
|  | ||||
|                 if (strack >= std::size(_fileheader.track)) { | ||||
|                     std::cout << fmt::format("SCP: cannot write track {} head {}, " | ||||
|                             "there are not not enough Track Data Headers.\n", | ||||
|                             cylinder, head); | ||||
|                     return; | ||||
|                 } | ||||
| 		ScpTrack trackheader = {0}; | ||||
| 		trackheader.header.track_id[0] = 'T'; | ||||
| 		trackheader.header.track_id[1] = 'R'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user