Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2020-23026: dhrystone-2.1.tar.gz: dhry_1.c | Fossies

A NULL pointer dereference in the main() function dhry_1.c of dhrystone 2.1 causes a denial of service (DoS).

CVE
#linux#dos

“Fossies” - the Fresh Open Source Software Archive ****Member “dhry_1.c” (25 Jul 1989, 11857 Bytes) of package /linux/privat/old/dhrystone-2.1.tar.gz:

As a special service “Fossies” has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about “dhry_1.c” see the Fossies “Dox” file reference documentation.

1 /\*
2 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
3 \*
4 \*                   "DHRYSTONE" Benchmark Program
5 \*                   -----------------------------
6\*                                                                            
7 \*  Version:    C, Version 2.1
8\*                                                                            
9 \*  File:       dhry\_1.c (part 2 of 3)

10 * 11 * Date: May 25, 1988 12 * 13 * Author: Reinhold P. Weicker 14 * 15 **************************************************************************** 16 */ 17 18 #include “dhry.h” 19 20 /* Global Variables: */ 21 22 Rec_Pointer Ptr_Glob, 23 Next_Ptr_Glob; 24 int Int_Glob; 25 Boolean Bool_Glob; 26 char Ch_1_Glob, 27 Ch_2_Glob; 28 int Arr_1_Glob [50]; 29 int Arr_2_Glob [50] [50]; 30 31 extern char *malloc (); 32 Enumeration Func_1 (); 33 /* forward declaration necessary since Enumeration may not simply be int */ 34 35 #ifndef REG 36 Boolean Reg = false; 37 #define REG 38 /* REG becomes defined as empty */ 39 /* i.e. no register variables */ 40 #else 41 Boolean Reg = true; 42 #endif 43 44 /* variables for time measurement: */ 45 46 #ifdef TIMES 47 struct tms time_info; 48 extern int times (); 49 /* see library function “times” */ 50 #define Too_Small_Time (2*HZ) 51 /* Measurements should last at least about 2 seconds */ 52 #endif 53 #ifdef TIME 54 extern long time(); 55 /* see library function “time” */ 56 #define Too_Small_Time 2 57 /* Measurements should last at least 2 seconds */ 58 #endif 59 #ifdef MSC_CLOCK 60 extern clock_t clock(); 61 #define Too_Small_Time (2*HZ) 62 #endif 63 64 long Begin_Time, 65 End_Time, 66 User_Time; 67 float Microseconds, 68 Dhrystones_Per_Second; 69 70 /* end of variables for time measurement */ 71 72 73 main () 74 /*****/ 75 76 /* main program, corresponds to procedures */ 77 /* Main and Proc_0 in the Ada version */ 78 { 79 One_Fifty Int_1_Loc; 80 REG One_Fifty Int_2_Loc; 81 One_Fifty Int_3_Loc; 82 REG char Ch_Index; 83 Enumeration Enum_Loc; 84 Str_30 Str_1_Loc; 85 Str_30 Str_2_Loc; 86 REG int Run_Index; 87 REG int Number_Of_Runs; 88 89 /* Initializations */ 90 91 Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); 92 Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); 93 94 Ptr_Glob->Ptr_Comp = Next_Ptr_Glob; 95 Ptr_Glob->Discr = Ident_1; 96 Ptr_Glob->variant.var_1.Enum_Comp = Ident_3; 97 Ptr_Glob->variant.var_1.Int_Comp = 40; 98 strcpy (Ptr_Glob->variant.var_1.Str_Comp, 99 “DHRYSTONE PROGRAM, SOME STRING”); 100 strcpy (Str_1_Loc, “DHRYSTONE PROGRAM, 1’ST STRING”); 101 102 Arr_2_Glob [8][7] = 10; 103 /* Was missing in published program. Without this statement, */ 104 /* Arr_2_Glob [8][7] would have an undefined value. */ 105 /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ 106 /* overflow may occur for this array element. */ 107 108 printf (“\n”); 109 printf (“Dhrystone Benchmark, Version 2.1 (Language: C)\n”); 110 printf (“\n”); 111 if (Reg) 112 { 113 printf (“Program compiled with ‘register’ attribute\n”); 114 printf (“\n”); 115 } 116 else 117 { 118 printf (“Program compiled without ‘register’ attribute\n”); 119 printf (“\n”); 120 } 121 printf ("Please give the number of runs through the benchmark: "); 122 { 123 int n; 124 scanf ("%d", &n); 125 Number_Of_Runs = n; 126 } 127 printf (“\n”); 128 129 printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs); 130 131 /***************/ 132 /* Start timer */ 133 /***************/ 134
135 #ifdef TIMES 136 times (&time_info); 137 Begin_Time = (long) time_info.tms_utime; 138 #endif 139 #ifdef TIME 140 Begin_Time = time ( (long *) 0); 141 #endif 142 #ifdef MSC_CLOCK 143 Begin_Time = clock(); 144 #endif 145 146 for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) 147 { 148 149 Proc_5(); 150 Proc_4(); 151 /* Ch_1_Glob == 'A’, Ch_2_Glob == 'B’, Bool_Glob == true */ 152 Int_1_Loc = 2; 153 Int_2_Loc = 3; 154 strcpy (Str_2_Loc, “DHRYSTONE PROGRAM, 2’ND STRING”); 155 Enum_Loc = Ident_2; 156 Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc); 157 /* Bool_Glob == 1 */ 158 while (Int_1_Loc < Int_2_Loc) /* loop body executed once */ 159 { 160 Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc; 161 /* Int_3_Loc == 7 */ 162 Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc); 163 /* Int_3_Loc == 7 */ 164 Int_1_Loc += 1; 165 } /* while */ 166 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ 167 Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc); 168 /* Int_Glob == 5 */ 169 Proc_1 (Ptr_Glob); 170 for (Ch_Index = 'A’; Ch_Index <= Ch_2_Glob; ++Ch_Index) 171 /* loop body executed twice */ 172 { 173 if (Enum_Loc == Func_1 (Ch_Index, ‘C’)) 174 /* then, not executed */ 175 { 176 Proc_6 (Ident_1, &Enum_Loc); 177 strcpy (Str_2_Loc, “DHRYSTONE PROGRAM, 3’RD STRING”); 178 Int_2_Loc = Run_Index; 179 Int_Glob = Run_Index; 180 } 181 } 182 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ 183 Int_2_Loc = Int_2_Loc * Int_1_Loc; 184 Int_1_Loc = Int_2_Loc / Int_3_Loc; 185 Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc; 186 /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */ 187 Proc_2 (&Int_1_Loc); 188 /* Int_1_Loc == 5 */ 189 190 } /* loop “for Run_Index” */ 191 192 /**************/ 193 /* Stop timer */ 194 /**************/ 195
196 #ifdef TIMES 197 times (&time_info); 198 End_Time = (long) time_info.tms_utime; 199 #endif 200 #ifdef TIME 201 End_Time = time ( (long *) 0); 202 #endif 203 #ifdef MSC_CLOCK 204 End_Time = clock(); 205 #endif 206 207 printf (“Execution ends\n”); 208 printf (“\n”); 209 printf (“Final values of the variables used in the benchmark:\n”); 210 printf (“\n”); 211 printf ("Int_Glob: %d\n", Int_Glob); 212 printf (" should be: %d\n", 5); 213 printf (“Bool_Glob: %d\n", Bool_Glob); 214 printf (" should be: %d\n", 1); 215 printf (“Ch_1_Glob: %c\n", Ch_1_Glob); 216 printf (" should be: %c\n", ‘A’); 217 printf (“Ch_2_Glob: %c\n", Ch_2_Glob); 218 printf (" should be: %c\n", ‘B’); 219 printf (“Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]); 220 printf (" should be: %d\n", 7); 221 printf (“Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]); 222 printf (" should be: Number_Of_Runs + 10\n”); 223 printf (“Ptr_Glob->\n”); 224 printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp); 225 printf (" should be: (implementation-dependent)\n”); 226 printf (" Discr: %d\n", Ptr_Glob->Discr); 227 printf (" should be: %d\n", 0); 228 printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp); 229 printf (" should be: %d\n", 2); 230 printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp); 231 printf (" should be: %d\n", 17); 232 printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp); 233 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n”); 234 printf (“Next_Ptr_Glob->\n”); 235 printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp); 236 printf (" should be: (implementation-dependent), same as above\n”); 237 printf (" Discr: %d\n", Next_Ptr_Glob->Discr); 238 printf (" should be: %d\n", 0); 239 printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); 240 printf (" should be: %d\n", 1); 241 printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp); 242 printf (" should be: %d\n", 18); 243 printf (" Str_Comp: %s\n", 244 Next_Ptr_Glob->variant.var_1.Str_Comp); 245 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n”); 246 printf ("Int_1_Loc: %d\n", Int_1_Loc); 247 printf (" should be: %d\n", 5); 248 printf ("Int_2_Loc: %d\n", Int_2_Loc); 249 printf (" should be: %d\n", 13); 250 printf ("Int_3_Loc: %d\n", Int_3_Loc); 251 printf (" should be: %d\n", 7); 252 printf ("Enum_Loc: %d\n", Enum_Loc); 253 printf (" should be: %d\n", 1); 254 printf (“Str_1_Loc: %s\n", Str_1_Loc); 255 printf (" should be: DHRYSTONE PROGRAM, 1’ST STRING\n”); 256 printf (“Str_2_Loc: %s\n", Str_2_Loc); 257 printf (" should be: DHRYSTONE PROGRAM, 2’ND STRING\n”); 258 printf (“\n”); 259 260 User_Time = End_Time - Begin_Time; 261 262 if (User_Time < Too_Small_Time) 263 { 264 printf (“Measured time too small to obtain meaningful results\n”); 265 printf (“Please increase number of runs\n”); 266 printf (“\n”); 267 } 268 else 269 { 270 #ifdef TIME 271 Microseconds = (float) User_Time * Mic_secs_Per_Second 272 / (float) Number_Of_Runs; 273 Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time; 274 #else 275 Microseconds = (float) User_Time * Mic_secs_Per_Second 276 / ((float) HZ * ((float) Number_Of_Runs)); 277 Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs) 278 / (float) User_Time; 279 #endif 280 printf ("Microseconds for one run through Dhrystone: "); 281 printf ("%6.1f \n", Microseconds); 282 printf ("Dhrystones per Second: "); 283 printf ("%6.1f \n", Dhrystones_Per_Second); 284 printf (“\n”); 285 } 286
287 } 288 289 290 Proc_1 (Ptr_Val_Par) 291 /******************/ 292 293 REG Rec_Pointer Ptr_Val_Par; 294 /* executed once */ 295 { 296 REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
297 /* == Ptr_Glob_Next */ 298 /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ 299 /* corresponds to “rename” in Ada, “with” in Pascal */ 300
301 structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob); 302 Ptr_Val_Par->variant.var_1.Int_Comp = 5; 303 Next_Record->variant.var_1.Int_Comp 304 = Ptr_Val_Par->variant.var_1.Int_Comp; 305 Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; 306 Proc_3 (&Next_Record->Ptr_Comp); 307 /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp 308 == Ptr_Glob->Ptr_Comp */ 309 if (Next_Record->Discr == Ident_1) 310 /* then, executed */ 311 { 312 Next_Record->variant.var_1.Int_Comp = 6; 313 Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, 314 &Next_Record->variant.var_1.Enum_Comp); 315 Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; 316 Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, 317 &Next_Record->variant.var_1.Int_Comp); 318 } 319 else /* not executed */ 320 structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp); 321 } /* Proc_1 */ 322 323 324 Proc_2 (Int_Par_Ref) 325 /******************/ 326 /* executed once */ 327 /* *Int_Par_Ref == 1, becomes 4 */ 328 329 One_Fifty *Int_Par_Ref; 330 { 331 One_Fifty Int_Loc;
332 Enumeration Enum_Loc; 333 334 Int_Loc = *Int_Par_Ref + 10; 335 do /* executed once */ 336 if (Ch_1_Glob == ‘A’) 337 /* then, executed */ 338 { 339 Int_Loc -= 1; 340 *Int_Par_Ref = Int_Loc - Int_Glob; 341 Enum_Loc = Ident_1; 342 } /* if */ 343 while (Enum_Loc != Ident_1); /* true */ 344 } /* Proc_2 */ 345 346 347 Proc_3 (Ptr_Ref_Par) 348 /******************/ 349 /* executed once */ 350 /* Ptr_Ref_Par becomes Ptr_Glob */ 351 352 Rec_Pointer *Ptr_Ref_Par; 353 354 { 355 if (Ptr_Glob != Null) 356 /* then, executed */ 357 *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; 358 Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); 359 } /* Proc_3 */ 360 361 362 Proc_4 () /* without parameters */ 363 /*******/ 364 /* executed once */ 365 { 366 Boolean Bool_Loc; 367 368 Bool_Loc = Ch_1_Glob == 'A’; 369 Bool_Glob = Bool_Loc | Bool_Glob; 370 Ch_2_Glob = 'B’; 371 } /* Proc_4 */ 372 373 374 Proc_5 () /* without parameters */ 375 /*******/ 376 /* executed once */ 377 { 378 Ch_1_Glob = 'A’; 379 Bool_Glob = false; 380 } /* Proc_5 */ 381 382 383 /* Procedure for the assignment of structures, */ 384 /* if the C compiler doesn’t support this feature */ 385 #ifdef NOSTRUCTASSIGN 386 memcpy (d, s, l) 387 register char *d; 388 register char *s; 389 register int l; 390 { 391 while (l–) *d++ = *s++; 392 } 393 #endif 394 395

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907