Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/mseed2sac-2.3+ds1/src/fdzipstream.c Examining data/mseed2sac-2.3+ds1/src/fdzipstream.h Examining data/mseed2sac-2.3+ds1/src/mseed2sac.c Examining data/mseed2sac-2.3+ds1/src/sacformat.h FINAL RESULTS: data/mseed2sac-2.3+ds1/src/mseed2sac.c:26:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #define access _access data/mseed2sac-2.3+ds1/src/mseed2sac.c:548:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access (outfile, F_OK)) data/mseed2sac-2.3+ds1/src/mseed2sac.c:1541:16: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. fields = sscanf (lastfield, "%s", filename); data/mseed2sac-2.3+ds1/src/fdzipstream.c:141:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy ( writeBuffer, entry, writeBufferSize ); data/mseed2sac-2.3+ds1/src/fdzipstream.c:637:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (zstream->buffer+packed, zentry->Name, zentry->NameLength); packed += zentry->NameLength; data/mseed2sac-2.3+ds1/src/fdzipstream.c:860:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (zstream->buffer+packed, zentry->Name, zentry->NameLength); data/mseed2sac-2.3+ds1/src/fdzipstream.c:1106:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (ZS->buffer+*O, &V, 2); data/mseed2sac-2.3+ds1/src/fdzipstream.c:1112:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (ZS->buffer+*O, &V, 4); data/mseed2sac-2.3+ds1/src/fdzipstream.c:1118:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (ZS->buffer+*O, &V, 8); data/mseed2sac-2.3+ds1/src/fdzipstream.h:58:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char Name[ZENTRY_NAME_LENGTH]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:54:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char *metafields[MAXMETAFIELDS]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:115:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char srcname[50]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:116:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char prevsrcname[50]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:117:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char starttime[50]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:149:23: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). else if ((zipfp = fopen (zipfile, "wb")) == NULL) /* Open output ZIP file */ data/mseed2sac-2.3+ds1/src/mseed2sac.c:309:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char outfile[1024]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:310:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char baseoutfile[1024]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:627:16: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((ofp = fopen (outfile, "wb")) == NULL) data/mseed2sac-2.3+ds1/src/mseed2sac.c:703:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[2000]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:725:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (bp, "%#15.7g", *(fhp + fidx)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:738:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (bp, "%10d", *(ihp + fidx)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:751:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (bp, "%-8.8s%-16.16s", shp, shp + 8); data/mseed2sac-2.3+ds1/src/mseed2sac.c:758:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (bp, "%-8.8s", shp + (fidx * 8)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:770:16: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((ofp = fopen (outfile, "wb")) == NULL) data/mseed2sac-2.3+ds1/src/mseed2sac.c:822:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf (bp, "%#15.7g", *(fdata + fidx)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:918:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char sacnetwork[9]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:919:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char sacstation[9]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:920:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char saclocation[9]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:921:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char sacchannel[9]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:1477:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line[1024]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:1481:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char filename[1024]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:1487:13: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((fp = fopen (listfile, "rb")) == NULL) data/mseed2sac-2.3+ds1/src/mseed2sac.c:1742:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line[1024]; data/mseed2sac-2.3+ds1/src/mseed2sac.c:1749:14: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((mfp = fopen (metafile, "rb")) == NULL) data/mseed2sac-2.3+ds1/src/mseed2sac.c:1821:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (newlp->key, key, keylen); data/mseed2sac-2.3+ds1/src/mseed2sac.c:1827:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (newlp->data, data, datalen); data/mseed2sac-2.3+ds1/src/sacformat.h:135:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kstnm[8]; /* F station name */ data/mseed2sac-2.3+ds1/src/sacformat.h:136:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kevnm[16]; /* event name */ data/mseed2sac-2.3+ds1/src/sacformat.h:137:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char khole[8]; /* man-made event name */ data/mseed2sac-2.3+ds1/src/sacformat.h:138:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ko[8]; /* event origin time id */ data/mseed2sac-2.3+ds1/src/sacformat.h:139:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ka[8]; /* 1st arrival time ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:140:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt0[8]; /* time pick 0 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:141:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt1[8]; /* time pick 1 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:142:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt2[8]; /* time pick 2 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:143:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt3[8]; /* time pick 3 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:144:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt4[8]; /* time pick 4 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:145:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt5[8]; /* time pick 5 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:146:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt6[8]; /* time pick 6 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:147:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt7[8]; /* time pick 7 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:148:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt8[8]; /* time pick 8 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:149:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kt9[8]; /* time pick 9 ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:150:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kf[8]; /* end of event ident */ data/mseed2sac-2.3+ds1/src/sacformat.h:151:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kuser0[8]; /* available to user */ data/mseed2sac-2.3+ds1/src/sacformat.h:152:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kuser1[8]; /* available to user */ data/mseed2sac-2.3+ds1/src/sacformat.h:153:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kuser2[8]; /* available to user */ data/mseed2sac-2.3+ds1/src/sacformat.h:154:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kcmpnm[8]; /* F component name */ data/mseed2sac-2.3+ds1/src/sacformat.h:155:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char knetwk[8]; /* network name */ data/mseed2sac-2.3+ds1/src/sacformat.h:156:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kdatrd[8]; /* date data read */ data/mseed2sac-2.3+ds1/src/sacformat.h:157:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char kinst[8]; /* instrument name */ data/mseed2sac-2.3+ds1/src/fdzipstream.c:592:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (zentry->Name, (name)?name:"", ZENTRY_NAME_LENGTH - 1); data/mseed2sac-2.3+ds1/src/fdzipstream.c:593:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). zentry->NameLength = strlen (zentry->Name); data/mseed2sac-2.3+ds1/src/mseed2sac.c:221:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (prevsrcname, srcname, sizeof (prevsrcname)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:226:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (prevsrcname, srcname, sizeof (prevsrcname)); data/mseed2sac-2.3+ds1/src/mseed2sac.c:729:5: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf (bp, "\n"); data/mseed2sac-2.3+ds1/src/mseed2sac.c:742:5: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf (bp, "\n"); data/mseed2sac-2.3+ds1/src/mseed2sac.c:763:5: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf (bp, "\n"); data/mseed2sac-2.3+ds1/src/mseed2sac.c:826:7: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf (bp, "\n"); data/mseed2sac-2.3+ds1/src/mseed2sac.c:1230:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen (argvec[optind]) > 1) data/mseed2sac-2.3+ds1/src/mseed2sac.c:1238:57: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (!addnode (&filelist, NULL, 0, argvec[optind], strlen (argvec[optind]) + 1)) data/mseed2sac-2.3+ds1/src/mseed2sac.c:1553:51: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (!addnode (&filelist, NULL, 0, filename, strlen (filename) + 1)) ANALYSIS SUMMARY: Hits = 70 Lines analyzed = 3459 in approximately 0.13 seconds (27255 lines/second) Physical Source Lines of Code (SLOC) = 2394 Hits@level = [0] 117 [1] 11 [2] 56 [3] 0 [4] 3 [5] 0 Hits@level+ = [0+] 187 [1+] 70 [2+] 59 [3+] 3 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 78.1119 [1+] 29.2398 [2+] 24.6449 [3+] 1.25313 [4+] 1.25313 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.