Mitigate Baron SameEdit (CVE-2021-3156) vulnerability

alpine 3.9
buffer weakness #11


Weakness Breakdown


Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:



The highlighted line of code below is the trigger point of this particular Alpine 3.9 buffer weakness.

         fileinfo->time_write = fileinfo->data.ftLastWriteTime.dwLowDateTime;
    *retvalP = found;

static void
fileFindNextPosix(TFileFind * const filefindP,
                  TFileInfo * const fileinfoP,
                  bool *      const retvalP) {

#ifndef _WIN32
    struct dirent * deP;

    deP = readdir(filefindP->handle);
    if (deP) {
        char z[NAME_MAX+1];
        struct stat fs;

        strcpy(fileinfoP->name, deP->d_name);
        strcpy(z, filefindP->path);
        strncat(z, "/",NAME_MAX);
        strncat(z, fileinfoP->name, NAME_MAX);
        z[NAME_MAX] = '\0';
        stat(z, &fs);

        if (fs.st_mode & S_IFDIR)
            fileinfoP->attrib = A_SUBDIR;
            fileinfoP->attrib = 0;

        fileinfoP->size       = fs.st_size;
        fileinfoP->time_write = fs.st_mtime;
        *retvalP = true;
    } else
        *retvalP = false;

FileFindNext(TFileFind * const filefindP,
             TFileInfo * const fileinfo) {

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.