dotpcap / sharppcap

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
1.31k stars 267 forks source link

PosixTimeval.cs incorrect Microsecond output from ToString() #14

Closed bucweat closed 7 years ago

bucweat commented 7 years ago

In sharppcap/SharpPcap/PosixTimeval.cs, line 271: method sb.Append(MicroSeconds); is incorrect for values of MicroSeconds < 100000. For example, for seconds = 1 and Microseconds = 12345, resulting value returned by ToString() is 1.12345. It should be 1.012345.

Solution is to replace line 271 sb.Append(MicroSeconds); with sb.AppendFormat("{0:000000}",MicroSeconds);

chmorgan commented 7 years ago

Added a unit test and pushed this out just a second ago. Thank you again for reporting it.