Skip to content

Commit

Permalink
Get rid of (insecure) SNMP_MAXPATH in mkdirhier()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Safranek committed Jan 10, 2012
1 parent 8016890 commit 8850616
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion snmplib/system.c
Expand Up @@ -1022,9 +1022,13 @@ mkdirhier(const char *pathname, mode_t mode, int skiplast)
struct stat sbuf;
char *ourcopy = strdup(pathname);
char *entry;
char buf[SNMP_MAXPATH];
char *buf;
char *st = NULL;

buf = malloc(strlen(pathname));
if (!buf)
return SNMPERR_GENERR;

#if defined (WIN32) || defined (cygwin)
/* convert backslash to forward slash */
for (entry = ourcopy; *entry; entry++)
Expand Down Expand Up @@ -1069,6 +1073,7 @@ mkdirhier(const char *pathname, mode_t mode, int skiplast)
#endif
{
free(ourcopy);
free(buf);
return SNMPERR_GENERR;
}
} else {
Expand All @@ -1080,11 +1085,13 @@ mkdirhier(const char *pathname, mode_t mode, int skiplast)
* ack! can't make a directory on top of a file
*/
free(ourcopy);
free(buf);
return SNMPERR_GENERR;
}
}
}
free(ourcopy);
free(buf);
return SNMPERR_SUCCESS;
}

Expand Down

0 comments on commit 8850616

Please sign in to comment.