Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quiz question
Message
From
17/05/2014 04:17:28
 
 
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01600139
Message ID:
01600142
Views:
60
>From the GCHG competition :
>
>Q. Sometimes security vulnerabilities are simple coding mistakes that even the most seasoned developers can make. What is wrong with the following lines of (C#) code to compute a date range to filter a list of results? What would be a better approach?
var currentDate = DateTime.Now;
>var startDate = new DateTime(currentDate.Year - 1, currentDate.Month, currentDate.Day);
>var endDate = currentDate;
>// Filter the results etc.
Better approach
DateTime startDate = currentDate.AddMonths(-12);
Also, ToDay may be a better choice
var currentDate = DateTime.ToDay;
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform