Skip to content

Commit 4aa91d7

Browse files
kphuphanwoemarkbrown314
authored andcommitted
Improved SHMEM_SYMMETRIC_SIZE Validation
Issue #1185 If SHMEM_SYMMETRIC_SIZE contains invalid characters, return error. Signed-off-by: Kitibodee Phuphanwoe <kitibodee.ph@ksu.ac.th>
1 parent 8649160 commit 4aa91d7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/shmem_env.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ atol_scaled(char *str, shmem_internal_env_size *out)
3838
double p = -1.0;
3939
char f;
4040

41-
n = sscanf(str, "%lf%c", &p, &f);
41+
if (2 == sscanf(str, "%lf%c%n", &p, &f, &n)) {
42+
if (str[n] != '\0') {
43+
fprintf(stderr, "Invalid size in environment variable\n");
44+
return 1;
45+
}
4246

43-
if (n == 2) {
4447
switch (f) {
4548
case 'k':
4649
case 'K':

0 commit comments

Comments
 (0)