‫Hello and welcome, everybody.
‫Someone found a bug in the file system functionality, which I want to fix, I correct all my mistakes.
‫Unfortunately, part of software development, there's always bugs.
‫Even the Linux kernel is having daily bug fixes.
‫Right.
‫So the bug is located in fat 16.
‫To prop a string online three or six year, it might be on a different line for you, depending which
‫stage you are on the course, although don't skip to this lecture if you haven't finished the course
‫yet, because obviously you need to be on you need to naturally be at this lecture and have followed
‫the course all the way through.
‫Don't make changes if you're way behind.
‫Right.
‫OK, so you'll see fat sticks and proper string.
‫Now this obviously checks for an old Terminator or a space, OK?
‫And it will populate the the output.
‫OK, now that's all fine, except if we go to fat 16 gatefold relative filename.
‫And we take a look at the item filename, which is, in fact directory item, you'll see it's eight
‫bytes.
‫Now, the fat 16 specification requires there to be a space for any bytes that we're not using.
‫So, for example, if the filename is only three bytes, we would need to then fill the the other five
‫bytes with spaces.
‫But what happens if you use the full eight bytes for the filename?
‫Well, then there's no space.
‫And if there's no space, then this while loop has no reason to stop, OK?
‫And that's obviously a huge bugbear because unless there's an old Terminator or space, we will keep
‫going forever.
‫So, you know, I always fix my mistakes and I can only apologize that there was a mistake.
‫However, in software development, bugs completely natural.
‫They're part of the process, as I'm sure you're aware.
‫So as long as they get them fixed, I think that's what matters.
‫So what we're going to do then is we're going to fix this, OK?
‫OK, so all we're going to do to fix this bug, we're just going to put a size variable here and this
‫will be the size that is provided.
‫OK, so what we're now going to do is we're going to say size of item filename.
‫So obviously that'll pass in here.
‫OK, so it's basically saying that there's a maximum of eight bytes in the buffer you're processing,
‫OK, in the input buffer.
‫So that's important.
‫OK, and we're going to have to do the same for extension as well.
‫OK, OK, so now what we're going to do is we're going to say integer I equals zero.
‫OK, and just by here we're going to say a plus plus.
‫OK, now just by here we're going to say if I is above our equal size, minus one.
‫Now if that happens, that means we've overflowed the size.
‫OK, so we need to deal with that.
‫So, for example, if we had a size of one, it means that we're allowed to process one bite would come
‫in here, we would check that bite.
‫We would then do what we need to do, added to the output buffer and so on.
‫And then what we would do is, is we would say if I which is zero, by the way, is above our equal
‫one minus one, which is zero, by the way.
‫So that would be true.
‫So now we're basically saying, OK, we've processed up to the size.
‫We can't go any further.
‫So if we can't go any further than we need to break.
‫But if we break, we'll come down here and then we'll check that next spike, which we don't want to
‫we don't want that.
‫So what we're instead going to do in this particular case is we're just going to go out equals zero
‫zero zero, OK?
‫And then we are just going to return because we don't want to do anything else.
‫OK, so that's how that works.
‫So I would go in here with Loop through these.
‫OK, let's take the filename as an example right now.
‫You know what the extension, because it's it's less than three bytes the extension.
‫Right.
‫OK, so if we imagine the extension is.
‫ABC.
‫OK, so this is ABC then the size is three, OK, because that's how much the extension can hold.
‫OK, three bites.
‫So we come in here, we read the first bite.
‫So we say, is the input a no.
‫No, it isn't.
‫Is the input espace.
‫No, it isn't.
‫OK, then we can we can proceed.
‫So we come in here.
‫We said the that we set the current byte in the output.
‫OK, so he gets put into the first bite of the output here and then we increment the pointer, OK.
‫And then we also increment the endpoint to here as well.
‫OK, so at this point I zero is I above or equal three minus one, which is to know it isn't because
‫zero is not above or equal to.
‫OK, so we ignore that and we do a plus plus plus now one.
‫So we come back around with the next part B.
‫OK, we incremented those things again is one above were equal to no, it isn't.
‫So we look back around, OK, so beas now set in the output and then we do apress plus.
‫So I is now equal to two.
‫So we look back around and we put C in the output buffer.
‫OK, is two above were equal to.
‫Yes it is.
‫So we then said the null terminated and we return.
‫So we're left with only A.B.C..
‫OK, so that should work absolutely fine.
‫So, you know, I was actually thinking this return can even be improved.
‫OK, so rather than worrying about this, we could just two out equals zero zero zero.
‫Now, that does mean that even if the input is zero zero zero, we're still going to do that.
‫But I don't think is a big deal because we have quite a large budget buffer to work with Sergeant Bitts.
‫I don't think this is a problem by here, because obviously this functions only concerned with the size
‫of the input buffer.
‫That's all we really care about in this example, and since the filesystem can only hold, what, eight,
‫eight bytes filename and three bytes extension and we have one hundred eight bytes to work with and
‫there's no concern here.
‫There isn't.
‫Right.
‫So just get rid of that and then we can just do a break and then that's a lot cleaner, right.
‫That's a lot cleaner at that stage then, and in fact, that even means we don't need this.
‫We no longer need that because we always do the Terminator here, so, you know, we can just put a
‫little comment here saying we can't process anymore since we have exceeded the empathises, OK?
‫And yeah, that should work really well.
‫And that's a lot cleaner, as you can see.
‫So we're now going to just make clean and build this.
‫So we're going to say make clean, build that.
‫S.H. Everything should go OK.
‫Good, Cribben.
‫And we're going to run kumu and we see everything works as as expected.
‫So, yeah, that that concludes this lecture, guys, and we fixed the bug.
‫And I appreciate your patience with the matter.
‫I do like to keep bugs to a minimum, but obviously, unfortunately, mistakes happen.
‫But I will always correct my mistakes.
‫So thanks very much for your patience.
‫And I hope you've enjoyed the cost so far.