This is literally true, but there is a much deeper significance. When one offered injury to Buddha, he refused to accept the injury, classifying it as a gift acceptable or unacceptable, which when refused, was returned to the giver. The same idea is in Christ's "Resist not evil." Refusing to accept evil as evil, declining to recognize anything as harm to the self, the intended harm or evil falls back upon the schemer.
The same law can be observed in the life of the great Sufi, Byazid Bistami. When he declared the universality of God in such a way as to betray the Great Secret, he called upon his disciples to kill him; instead, their knives were turned back upon themselves. In other words, when we rise above duality, when we touch infinity, we can no longer be effected by the finite. And who wishes to do good to the sages receives good; who desires to perform evil, receives evil. In that condition the sage is the master of Karma, above the influence of Karma.