Skip to content

Commit ff62288

Browse files
authored
add codeql fixes/suppressions (#664)
1 parent e46452f commit ff62288

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

openbsd-compat/getopt_long.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
383383
/*
384384
* If we have "-" do nothing, if "--" we are done.
385385
*/
386-
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
386+
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { // CodeQL [SM01947]: upstream code; place re-assigned in previous line
387387
optind++;
388388
place = EMSG;
389389
/*

regress/unittests/test_helper/test_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ main(int argc, char **argv)
159159
/* Handle systems without __progname */
160160
if (__progname == NULL) {
161161
__progname = strrchr(argv[0], '/');
162-
if (__progname == NULL || (__progname[0] != '\0' && __progname[1] == '\0')) // fix CodeQL SM01947
162+
if (__progname == NULL || (__progname[0] != '\0' && __progname[1] == '\0')) // CodeQL [SM01947]: __progname may be longer than 1 byte and prev. checks handle if smaller
163163
__progname = argv[0];
164164
else
165165
__progname++;
@@ -423,7 +423,7 @@ tohex(const void *_s, size_t l)
423423
r[j++] = hex[(s[i] >> 4) & 0xf]; // CodeQL [SM02311]: tests rely on assert for NULL checks
424424
r[j++] = hex[s[i] & 0xf];
425425
}
426-
r[j] = '\0';
426+
r[j] = '\0'; // CodeQL [SM02311]: tests rely on assert for NULL checks
427427
return r;
428428
}
429429

regress/unittests/win32compat/tests.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ dup_str(char *inStr)
3535

3636
int len = strlen(inStr);
3737
char *outStr = malloc(len + 1);
38+
if (NULL == outStr)
39+
return NULL;
3840
strncpy(outStr, inStr, len);
3941
outStr[len] = '\0';
4042
return outStr;

0 commit comments

Comments
 (0)