Ceiling light junction box multiple wire detection
It appears, at one time, that the circuit took way too much heat.  I would not be comfortable leaving it like this, but I have done wiring for years.  When the breaker to the light is off, determine what else is on that circuit.  Then look at what these normally pull.  I am assuming this is a house 30+ years old.  I see 6 ground wires going into the electrical cap, but only 5 white neutrals going into that cap.  A question I have for you is why are you changing the light?  Was it a "honey, I don't like this light" or the light was not working correctly?  Do you have access to the wiring from above, like in the attic?  You can always just switch the light out and what you did by changing the light will not increase your chance of fire, but I would still check out what else is on that circuit.