Skip to content

Commit

Permalink
Add error reporting, increase path limits for module loads
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann authored Jul 6, 2024
1 parent 085583e commit c960f05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 2 additions & 3 deletions eggdrop-basic.conf
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ set ssl-capath "/etc/ssl/"
## Eggdrop, things change.

## This path specifies the path were Eggdrop should look for its modules.
## If you run the bot from the compilation directory, you will want to set
## this to "". If you use 'make install' (like all good kiddies do ;), this
## is a fine default. Otherwise, use your head :)
## If you use 'make install' (like all good kiddies do ;), this is a fine
## default. Otherwise, use your head :)
set mod-path "modules/"

#### CHANNELS MODULE ####
Expand Down
5 changes: 2 additions & 3 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,8 @@ die "Please make sure you edit your config file completely."
# Eggdrop, things change.

# This path specifies the path were Eggdrop should look for its modules.
# If you run the bot from the compilation directory, you will want to set
# this to "". If you use 'make install' (like all good kiddies do ;), this
# is a fine default. Otherwise, use your head :)
# If you use 'make install' (like all good kiddies do ;), this is a fine
# default. Otherwise, use your head :)
set mod-path "modules/"


Expand Down
13 changes: 9 additions & 4 deletions src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <errno.h>
#include <signal.h>
#include "main.h"
#include "modules.h"
Expand Down Expand Up @@ -694,6 +695,7 @@ int module_register(char *name, Function *funcs, int major, int minor)

const char *module_load(char *name)
{
size_t len;
module_entry *p;
char *e;
Function f;
Expand All @@ -702,7 +704,7 @@ const char *module_load(char *name)
#endif

#ifndef STATIC
char workbuf[1024];
char workbuf[PATH_MAX];
# ifdef MOD_USE_SHL
shl_t hand;
# endif
Expand All @@ -728,11 +730,14 @@ const char *module_load(char *name)

#ifndef STATIC
if (moddir[0] != '/') {
if (getcwd(workbuf, 1024) == NULL)
if (getcwd(workbuf, sizeof workbuf) == NULL) {
debug1("modules: getcwd(): %s\n", strerror(errno));
return MOD_BADCWD;
sprintf(&(workbuf[strlen(workbuf)]), "/%s%s." EGG_MOD_EXT, moddir, name);
}
len = strlen(workbuf);
snprintf(workbuf + len, (sizeof workbuf) - len, "/%s%s." EGG_MOD_EXT, moddir, name);
} else {
sprintf(workbuf, "%s%s." EGG_MOD_EXT, moddir, name);
snprintf(workbuf, sizeof workbuf, "%s%s." EGG_MOD_EXT, moddir, name);
}

# ifdef MOD_USE_SHL
Expand Down

0 comments on commit c960f05

Please sign in to comment.