diff options
Diffstat (limited to 'linden/indra/llprimitive/llprimitive.cpp')
-rw-r--r-- | linden/indra/llprimitive/llprimitive.cpp | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/linden/indra/llprimitive/llprimitive.cpp b/linden/indra/llprimitive/llprimitive.cpp index 3ddf92e..bbfa53e 100644 --- a/linden/indra/llprimitive/llprimitive.cpp +++ b/linden/indra/llprimitive/llprimitive.cpp | |||
@@ -760,15 +760,14 @@ U8 LLPrimitive::pCodeToLegacy(const LLPCode pcode) | |||
760 | 760 | ||
761 | // static | 761 | // static |
762 | // Don't crash or llerrs here! This function is used for debug strings. | 762 | // Don't crash or llerrs here! This function is used for debug strings. |
763 | const char * LLPrimitive::pCodeToString(const LLPCode pcode) | 763 | std::string LLPrimitive::pCodeToString(const LLPCode pcode) |
764 | { | 764 | { |
765 | static char pcode_string[255]; /* Flawfinder: ignore */ | 765 | std::string pcode_string; |
766 | 766 | ||
767 | U8 base_code = pcode & LL_PCODE_BASE_MASK; | 767 | U8 base_code = pcode & LL_PCODE_BASE_MASK; |
768 | pcode_string[0] = 0; | ||
769 | if (!pcode) | 768 | if (!pcode) |
770 | { | 769 | { |
771 | snprintf(pcode_string, sizeof(pcode_string), "null"); /* Flawfinder: ignore */ | 770 | pcode_string = "null"; |
772 | } | 771 | } |
773 | else if ((base_code) == LL_PCODE_LEGACY) | 772 | else if ((base_code) == LL_PCODE_LEGACY) |
774 | { | 773 | { |
@@ -776,66 +775,66 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode) | |||
776 | switch (pcode) | 775 | switch (pcode) |
777 | { | 776 | { |
778 | case LL_PCODE_LEGACY_GRASS: | 777 | case LL_PCODE_LEGACY_GRASS: |
779 | snprintf(pcode_string, sizeof(pcode_string), "grass"); /* Flawfinder: ignore */ | 778 | pcode_string = "grass"; |
780 | break; | 779 | break; |
781 | case LL_PCODE_LEGACY_PART_SYS: | 780 | case LL_PCODE_LEGACY_PART_SYS: |
782 | snprintf(pcode_string, sizeof(pcode_string), "particle system"); /* Flawfinder: ignore */ | 781 | pcode_string = "particle system"; |
783 | break; | 782 | break; |
784 | case LL_PCODE_LEGACY_AVATAR: | 783 | case LL_PCODE_LEGACY_AVATAR: |
785 | snprintf(pcode_string, sizeof(pcode_string), "avatar"); /* Flawfinder: ignore */ | 784 | pcode_string = "avatar"; |
786 | break; | 785 | break; |
787 | case LL_PCODE_LEGACY_TEXT_BUBBLE: | 786 | case LL_PCODE_LEGACY_TEXT_BUBBLE: |
788 | snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */ | 787 | pcode_string = "text bubble"; |
789 | break; | 788 | break; |
790 | case LL_PCODE_LEGACY_TREE: | 789 | case LL_PCODE_LEGACY_TREE: |
791 | snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */ | 790 | pcode_string = "tree"; |
792 | break; | 791 | break; |
793 | case LL_PCODE_TREE_NEW: | 792 | case LL_PCODE_TREE_NEW: |
794 | snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */ | 793 | pcode_string = "tree_new"; |
795 | break; | 794 | break; |
796 | default: | 795 | default: |
797 | snprintf(pcode_string, sizeof(pcode_string), "unknown legacy pcode %i",(U32)pcode); /* Flawfinder: ignore */ | 796 | pcode_string = llformat( "unknown legacy pcode %i",(U32)pcode); |
798 | } | 797 | } |
799 | } | 798 | } |
800 | else | 799 | else |
801 | { | 800 | { |
802 | char shape[32]; /* Flawfinder: ignore */ | 801 | std::string shape; |
803 | char mask[32]; /* Flawfinder: ignore */ | 802 | std::string mask; |
804 | if (base_code == LL_PCODE_CUBE) | 803 | if (base_code == LL_PCODE_CUBE) |
805 | { | 804 | { |
806 | snprintf(shape, sizeof(shape), "cube"); /* Flawfinder: ignore */ | 805 | shape = "cube"; |
807 | } | 806 | } |
808 | else if (base_code == LL_PCODE_CYLINDER) | 807 | else if (base_code == LL_PCODE_CYLINDER) |
809 | { | 808 | { |
810 | snprintf(shape, sizeof(shape), "cylinder"); /* Flawfinder: ignore */ | 809 | shape = "cylinder"; |
811 | } | 810 | } |
812 | else if (base_code == LL_PCODE_CONE) | 811 | else if (base_code == LL_PCODE_CONE) |
813 | { | 812 | { |
814 | snprintf(shape, sizeof(shape), "cone"); /* Flawfinder: ignore */ | 813 | shape = "cone"; |
815 | } | 814 | } |
816 | else if (base_code == LL_PCODE_PRISM) | 815 | else if (base_code == LL_PCODE_PRISM) |
817 | { | 816 | { |
818 | snprintf(shape, sizeof(shape), "prism"); /* Flawfinder: ignore */ | 817 | shape = "prism"; |
819 | } | 818 | } |
820 | else if (base_code == LL_PCODE_PYRAMID) | 819 | else if (base_code == LL_PCODE_PYRAMID) |
821 | { | 820 | { |
822 | snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */ | 821 | shape = "pyramid"; |
823 | } | 822 | } |
824 | else if (base_code == LL_PCODE_SPHERE) | 823 | else if (base_code == LL_PCODE_SPHERE) |
825 | { | 824 | { |
826 | snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */ | 825 | shape = "sphere"; |
827 | } | 826 | } |
828 | else if (base_code == LL_PCODE_TETRAHEDRON) | 827 | else if (base_code == LL_PCODE_TETRAHEDRON) |
829 | { | 828 | { |
830 | snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */ | 829 | shape = "tetrahedron"; |
831 | } | 830 | } |
832 | else if (base_code == LL_PCODE_VOLUME) | 831 | else if (base_code == LL_PCODE_VOLUME) |
833 | { | 832 | { |
834 | snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */ | 833 | shape = "volume"; |
835 | } | 834 | } |
836 | else if (base_code == LL_PCODE_APP) | 835 | else if (base_code == LL_PCODE_APP) |
837 | { | 836 | { |
838 | snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */ | 837 | shape = "app"; |
839 | } | 838 | } |
840 | else | 839 | else |
841 | { | 840 | { |
@@ -845,35 +844,27 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode) | |||
845 | U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); | 844 | U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); |
846 | if (base_code == LL_PCODE_APP) | 845 | if (base_code == LL_PCODE_APP) |
847 | { | 846 | { |
848 | snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ | 847 | mask = llformat( "%x", mask_code); |
849 | } | 848 | } |
850 | else if (mask_code & LL_PCODE_HEMI_MASK) | 849 | else if (mask_code & LL_PCODE_HEMI_MASK) |
851 | { | 850 | { |
852 | snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */ | 851 | mask = "hemi"; |
853 | } | 852 | } |
854 | else | 853 | else |
855 | { | 854 | { |
856 | snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ | 855 | mask = llformat( "%x", mask_code); |
857 | } | 856 | } |
858 | 857 | ||
859 | // extra sanity against snprintf() being naturally crap | ||
860 | mask[sizeof(mask)-1] = '\0'; | ||
861 | shape[sizeof(shape)-1] = '\0'; | ||
862 | |||
863 | if (mask[0]) | 858 | if (mask[0]) |
864 | { | 859 | { |
865 | snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */ | 860 | pcode_string = llformat( "%s-%s", shape.c_str(), mask.c_str()); |
866 | } | 861 | } |
867 | else | 862 | else |
868 | { | 863 | { |
869 | snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */ | 864 | pcode_string = llformat( "%s", shape.c_str()); |
870 | } | 865 | } |
871 | } | 866 | } |
872 | 867 | ||
873 | // Be really sure that pcode_string is nul-terminated after we've | ||
874 | // been using crappy snprintf() to build it. | ||
875 | pcode_string[sizeof(pcode_string)-1] = '\0'; | ||
876 | |||
877 | return pcode_string; | 868 | return pcode_string; |
878 | } | 869 | } |
879 | 870 | ||
@@ -993,7 +984,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai | |||
993 | S32 i; | 984 | S32 i; |
994 | 985 | ||
995 | /* | 986 | /* |
996 | LLString old_mask_string; | 987 | std::string old_mask_string; |
997 | for (i = 0; i < 9; i++) | 988 | for (i = 0; i < 9; i++) |
998 | { | 989 | { |
999 | if (old_face_mask & (1 << i)) | 990 | if (old_face_mask & (1 << i)) |
@@ -1005,7 +996,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai | |||
1005 | old_mask_string.append("0"); | 996 | old_mask_string.append("0"); |
1006 | } | 997 | } |
1007 | } | 998 | } |
1008 | LLString new_mask_string; | 999 | std::string new_mask_string; |
1009 | for (i = 0; i < 9; i++) | 1000 | for (i = 0; i < 9; i++) |
1010 | { | 1001 | { |
1011 | if (new_face_mask & (1 << i)) | 1002 | if (new_face_mask & (1 << i)) |