Question

Secure Coding Lab Zune Failure Part 2 Purpose: Explore the Zune Failure from December 2008. Tools:...

Secure Coding Lab
Zune Failure Part 2

Purpose: Explore the Zune Failure from December 2008.

Tools: Students can use any tool of their choice

Assignment: Students will do individual work. This is a follow-on to the previous lab.
The deliverable is an explanation of the code that resulted in the Microsoft Zune failure of December 31, 2008.
Enhanced Code is attached.

Deliverable: Analyzing the code, explain why it failed, show the specific lines of code with an explanation of why. And how to fix it.

So what’s the purpose of the while loop? To put it simply, it’s designed to get the number of years from the number of days since 1980 as well as a reminder of days out of the current year.
Keep in mind that you’re never supposed to retry the loop without committing some sort of action which will ultimately exit the loop:

1. year is set to ORIGINYEAR. Since ORIGINYEAR is 1980, any addition to year is added on top of 1980. This is fine because the hardware is passing the number of days since January 1, 1980.
2. Is the number of days greater than 365? If so, proceed. Otherwise, skip to number 6.
3. Is the current year a leap year? If so, proceed. Otherwise, subtract 365 from the number of days, add 1 to the number of years, and skip to number 5.
4. Is the number of days greater than 366? If so, subtract 366 from the number of days, add 1 to the number of years, and proceed. 5. retry number 2.
6. This is the loop exit point – success if you get here  

Code: #define ORIGINYEAR 1980
BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime)
{
int dayofweek, month, year;
UINT8 *month_tab;

//Calculate current day of the week
dayofweek = GetDayOfWeek(days);

year = ORIGINYEAR;

while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366; year += 1;
}
} else { days -= 365; year += 1;
}
}

// Determine whether it is a leap year
month_tab = (UINT8 *)((IsLeapYear(year))? monthtable_leap : monthtable);
for (month=0; month<12; month++)
{
if (days <= month_tab[month])
break;
days -= month_tab[month];
}
month += 1;
lpTime->wDay = days;
lpTime->wDayOfWeek = dayofweek;
lpTime->wMonth = month;
lpTime->wYear = year; return TRUE;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

From the given code,

The outcome is processed within the while loop. Initially, the while loop checks for the days are greater than 365, and it is true, then checking for leap year, and it is also true. But, in the following condition at if statement, if we have exactly 366 days, then it will not satisfy the condition and makes an infinite loop. So, the code failed to produce the required outcome.

We can modify the code inside the while to fix the issue,

while (days > 365){
   if (IsLeapYear(year)){
       if (days > 366){
           days -= 366;
           year += 1;
       } else
           break;
   }
   else{
       days -= 365;
       year += 1;
   }
}

The solution is, we can simple break the loop in such condition.

Add a comment
Know the answer?
Add Answer to:
Secure Coding Lab Zune Failure Part 2 Purpose: Explore the Zune Failure from December 2008. Tools:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source...

    SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source code (LargeProg1.c) through Canvas One source code file(unformatted text) will be submitted Here is INCOMPLETE code to get started: LargeProg1.c The file name must match the assignment The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas The code must be submitted on time in order to receive credit (11:59PM on the due date) Late submissions will...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

  • Discussion Questions: 1. What is the purpose of a distribution center? 2. Why does Cameron have...

    Discussion Questions: 1. What is the purpose of a distribution center? 2. Why does Cameron have eight warehouses? Why do you think Kelly believes six warehouses is better than eight? 3. What is the cost of holding inventory at Cameron? 4. Why should the decision to invest in inventory be different from investing in capital? 5. Do you think it is prudent to evaluate the future of the Atlanta warehouse independently from consideration of the other seven warehouses in the...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

  • Evaluate the arical writ the response in which you state your agreement or disagreement with writer...

    Evaluate the arical writ the response in which you state your agreement or disagreement with writer up un these questions guidelines 1) can empathy lead us astrary? how 2) our heart will always go out to the baby in the well, its a measure of our humanity. but empathy will have to yield to reason if humanity is to have a future can empathy yield to reason? how? thank you The Baby in the Well: The Case against Empathy* -Paul...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT