I am not sure what do ya mean by the fact infinitely long.....
Otherwise ya can work on the lines of shabbir...
check for a circular linked list....
that can be done by initialising two pointers and incrementing them at different interval...one at an increment of 1 other at an increment of 2...
if they meet....linked list is circular....
then ya can go to the previous node or previous to previous node and complete ur stuff....