As you noticed, the problem is in your check for the NUL terminator:
cmp $0, (%edx,%edi)
On 32-bit, the default operand size is a 32-bit word, therefore you'd need to end the string with 4× \0
in order for it to stop (or be lucky and encounter a zero-filled garbage after your string).
In this case, you want to load and check just one 8-bit character, therefore you need to use the b
suffix like this:
cmpb $0, (%edx,%edi)
You can see all the different suffixes here.