clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name html.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src/utils/cas -fcoverage-compilation-dir=/rootdir/src/utils/cas -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I ../../.. -D USE_WX_EXTENSIONS -D __GD__ -I /usr/include/libpng16 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/fribidi -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -D AVIF_DLL -I /usr/include/rav1e -I /usr/include/svt-av1 -D EB_DLL -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-register -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-12-16-222823-17165-1 -x c html.c
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | #include <stdio.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <unistd.h> |
| 32 | #include <sys/stat.h> |
| 33 | #include <sys/types.h> |
| 34 | #include <fcntl.h> |
| 35 | #include <string.h> |
| 36 | |
| 37 | #include "html.h" |
| 38 | #include "functions.h" |
| 39 | #include "version.h" |
| 40 | |
| 41 | int create_html(char *stats[20], char *lines[6], char template[120], char *path_for_html) |
| 42 | { |
| 43 | |
| 44 | char *path = NULL; |
| 45 | char version[25], upload[25], download[25]; |
| 46 | char *search[] = {"#VERSION#", "#CLIENT#", "#NICK#", "#UPLOADRATE#" , |
| 47 | "#DOWNLOADRATE#" , "#QUEUE#" , "#NUMSHARE#" , "#SESSIONUP#" , |
| 48 | "#SESSIONDOWN#" , "#TOTALUP#", "#TOTALDOWN#" , "#SERVER#" , "#IP#", |
| 49 | "#PORT#" }; |
| 50 | |
| 51 | snprintf(version, 25, "cas %s", CAS_VERSION); |
| 52 | snprintf(upload, 25, "%s kB/s", stats[7]); |
| 53 | snprintf(download, 25, "%s kB/s", stats[6]); |
| 54 | |
| 55 | char *repl[] = { version , lines[0] , stats[10] , upload , download , |
| 56 | stats[8] , stats[9] , stats[15] , stats[14] , stats[12] , stats[11] , |
| 57 | stats[1] , stats[2] , stats[3] }; |
| 58 | |
| 59 | |
| 60 | int fdTmpl; |
| 61 | if ((fdTmpl = open(template, O_RDONLY)) < 0) |
| |
| 62 | { |
| 63 | printf("\n\n%s\n",template); |
| 64 | perror("Could not open file"); |
| 65 | exit (43); |
| 66 | } |
| 67 | |
| 68 | struct stat sb; |
| 69 | if (fstat(fdTmpl, &sb) < 0) |
| |
| 70 | { |
| 71 | perror("Could not stat file"); |
| 72 | exit(43); |
| 73 | } |
| 74 | close(fdTmpl); |
| 75 | |
| 76 | |
| 77 | |
| 78 | size_t size = sb.st_size*2; |
| 79 | char *mem = calloc(size, 1); |
| 80 | if (NULL == mem) |
| 3 | | Assuming 'mem' is not equal to NULL | |
|
| |
| 81 | { |
| 82 | perror("Could not calloc\n"); |
| 83 | exit(44); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | size_t len = 0; |
| 88 | int ler; |
| 89 | FILE *fTmpl = fopen(template,"r"); |
| 5 | | Assuming pointer value is null | |
|
| 6 | | Assuming that 'fopen' fails | |
|
| 7 | | 'fTmpl' initialized here | |
|
| 90 | while ((ler=fgetc(fTmpl)) != EOF && len+1 < size) |
| 8 | | Null pointer passed to 1st parameter expecting 'nonnull' |
|
| 91 | { |
| 92 | mem[len++] = ler; |
| 93 | } |
| 94 | fclose(fTmpl); |
| 95 | |
| 96 | |
| 97 | |
| 98 | int t; |
| 99 | for (t=0; t<=13; t++) |
| 100 | { |
| 101 | |
| 102 | replace(mem, search[t], repl[t]); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | |
| 107 | path = get_amule_path("aMule-online-sign.html", 0, path_for_html); |
| 108 | |
| 109 | if (NULL == path) |
| 110 | { |
| 111 | perror("could not get the HTML path\n"); |
| 112 | free(mem); |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | FILE *fHTML = NULL; |
| 117 | if ((fHTML = fopen(path, "w")) == NULL) |
| 118 | { |
| 119 | perror("Unable to create file\n"); |
| 120 | free(path); |
| 121 | free(mem); |
| 122 | exit(44); |
| 123 | } |
| 124 | free(path); |
| 125 | |
| 126 | fprintf(fHTML, "%s", mem); |
| 127 | fclose(fHTML); |
| 128 | free(mem); |
| 129 | |
| 130 | printf("HTML file created.\n"); |
| 131 | |
| 132 | return 1; |
| 133 | } |