The Industrial Internet of Things (IIoT) has infiltrated our culture and is gaining traction in a variety of industrial applications. All of this is made possible by the use of 5G-connected massive Intelligent Sensing Devices (ISDs) and software-defined technology. It is sometimes desirable, and even required, to upgrade these ISDs without replacing hardware to make them smarter by adding new features and/or removing bugs through code dissemination. Using moving vehicles of the 5G-enabled Internet of Vehicles (IoV) infrastructure is one possible and efficient way to disseminate code. Specifically, safe code dissemination through a large number of vehicles in a 5G network has emerged as a critical issue. The motivation stems from the limitations of existing methods, often centralized and vulnerable to compromise, particularly in semi-connected networks. Therefore, this paper proposes an efficient and reliable Unmanned Aerial Vehicle (UAV)-assisted digital signature-based safe code dissemination framework for a 5G-enabled IIoT system. Our decentralized approach, which uses digital signatures and a Subjective Logic model, not only ensures code integrity but also identifies credible code mules, avoiding the pitfalls of traditional trust evaluation schemes. Furthermore, for UAV trajectory optimization, we redesign the trajectory with virtual waypoints to shorten the trajectory path for upgrading ISDs that were not upgraded due to the long-time trailing phenomenon. Our approach is useful in scenarios such as smart cities, where ISDs lack communication facilities. Through extensive experiments, our framework demonstrates superior efficiency and reliability compared to state-of-the-art methods.