Hi! Another (small) one if some of you guys have time to review some code. Cheers, Tanguy --- old/suckless-tools-38/dmenu/dmenu_path.c 2012-01-31 13:02:23.226833682 +0100 +++ suckless-tools-38/dmenu/dmenu_path.c 2012-01-31 14:01:10.282784329 +0100 @@ -46,7 +46,9 @@ void scan(void) { - char buf[PATH_MAX]; + char *buf = NULL; + char *new_buf = NULL; + size_t buf_size = 0; char *dir, *p; size_t i, count; struct dirent *ent; @@ -60,6 +62,13 @@ if(!(dp = opendir(dir))) continue; while((ent = readdir(dp))) { + buf_size = strlen(dir)+strlen(ent->d_name)+2; + if(!buf || strlen(buf) < buf_size) { + new_buf = realloc(buf, buf_size); + if(!new_buf) + die("realloc failed"); + buf = new_buf; + } snprintf(buf, sizeof buf, "%s/%s", dir, ent->d_name); if(ent->d_name[0] == '.' || access(buf, X_OK) < 0) continue; @@ -68,6 +77,7 @@ if(!(items[count-1] = strdup(ent->d_name))) die("strdup failed"); } + free(buf); closedir(dp); } qsort(items, count, sizeof *items, qstrcmp);
Attachment:
suckless-tools.hurd.patch
Description: Binary data