Since getgrent is supposed to leave errno unchanged upon EOF, I believe this exposes a bug in glibc (also note that ENOENT is not listed as a possible errno value in the POSIX spec for getgrent). It would seem that few getgrent-using applications care enough about robustness to check this particular condition.

So, regarding your patch, it'd be nice if you would investigate the possibility this is a glibc bug and get it fixed upstream. Considering the failure is no longer triggered with the latest coreutils snapshot, and the behavior it accommodates is not even standard-conforming, I'm inclined not to use the patch.