[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Patch for bug #44950
From: |
Mike Frysinger |
Subject: |
Re: [Nano-devel] Patch for bug #44950 |
Date: |
Sat, 9 Jan 2016 18:02:43 -0500 |
On 10 Jan 2016 01:13, Rishabh Dave wrote:
> +/* Determine whether the components in a path are valid directories. If
> + * some component is faulty return it, else return NULL. */
> + char *fault_in_path(const char *filename)
> +{
> + int lenpath, lenparent, lenpparent;
> + lenpath= strlen(filename);
> + char *parentdir = charalloc(lenpath * sizeof(char));
> + char *pparentdir = charalloc(lenpath * sizeof(char));
> + /* pparentdir implies parent of parent directory */
> + char *fault;
> + struct stat parentinfo, pparentinfo;
> +
> + strcpy(parentdir, filename);
> + parentdir = dirname(parentdir);
> + strcpy(pparentdir, parentdir);
> + pparentdir = dirname(pparentdir);
doesn't nano have a strdup helper ? malloc+strcpy == strdup.
> + /* If path exists, and parent directory is a directory and not a regular
> or
> + * some other file, then New File can be established, so return NULL. */
> + if (stat(parentdir, &parentinfo) != -1 && S_ISDIR(parentinfo.st_mode))
> + return NULL;
this leaks memory
> +
> + do {
> + /* Check if parent's parent directory exists, if not keep checking
> further.
> + * If it does exist, extract faulty directory, turn faulty_path flag on
> and
> + * return faulty directory. */
> + if (stat(pparentdir, &pparentinfo) == -1 ||
> !S_ISDIR(pparentinfo.st_mode)) {
> + strcpy(parentdir, pparentdir);
> + } else {
indentation is broken here
-mike
signature.asc
Description: Digital signature
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/03
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/03
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/05
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/06
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/09
- Re: [Nano-devel] Patch for bug #44950,
Mike Frysinger <=
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/10
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/11
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/11
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/12
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/15
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/15
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/15
- Re: [Nano-devel] Patch for bug #44950, Mike Frysinger, 2016/01/15
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/17
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/17