简体   繁体   中英

Segmentation fault in strlen when using FTS fts_open()

I have a bug that I've found boils down to this:

#include <sys/types.h>
#include <sys/stat.h>
#include <fts.h>
#include <stdlib.h>

int main () {
    char *LOG_ROOT = "/var/log";

    FTS *ftsp; 
    FTSENT *p, *chp;
    int fts_options = FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR;

    char *paths[] = { LOG_ROOT };
    fts_open(paths, fts_options, NULL);
}

Why does this segfault?

The first arg. is expected to be a NULL terminated array of character pointers.

char *paths[] = { LOG_ROOT, NULL};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM