Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dee2790

Browse files
committed
use variable instead of harcoded values
1 parent db767d7 commit dee2790

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

ModuleCmd_Avail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ static char *mkdirnm( char *dir,
13761376
/**
13771377
** Check whether the full path fits into the buffer
13781378
**/
1379-
if( (int) ( strlen( dir) + 1 + strlen( file) + 1 ) > MOD_BUFSIZE) {
1379+
if( (int) ( strlen( dir) + strlen(psep) + strlen( file) + 1 ) > MOD_BUFSIZE) {
13801380
if( OK != ErrorLogger( ERR_NAMETOLONG, LOC, dir, file, NULL))
13811381
return( NULL);
13821382
}

cmdUname.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void *UseId[] = { &UseId, Id };
3838
/** ************************************************************************ **/
3939

4040
#include "modules_def.h"
41+
#include <sys/param.h>
4142

4243
#ifdef HAVE_UNAME
4344
# include <sys/utsname.h>
@@ -65,7 +66,7 @@ typedef struct utsname {
6566
/** ************************************************************************ **/
6667

6768
#define NAMELEN (8 + 1) /** 8 chars + 1 terminator **/
68-
#define DOMAINLEN (64 + 1) /** 64 chars + 1 terminator **/
69+
#define DOMAINLEN (MAXHOSTNAMELEN + 1) /** from from <sys/param.h> **/
6970

7071
/** ************************************************************************ **/
7172
/** LOCAL DATA **/
@@ -122,6 +123,8 @@ int cmdUname(
122123
int length, /** argument string length **/
123124
namestruct_init = 0;
124125
/** namestruct init flag **/
126+
*domain ='\0';
127+
125128
#ifdef HAVE_UNAME
126129
struct utsname namestruct;
127130
#else
@@ -188,9 +191,13 @@ int cmdUname(
188191
if (-1 == getdomainname(domain, DOMAINLEN))
189192
if (OK != ErrorLogger(ERR_GETDOMAINNAME, LOC, NULL))
190193
return (TCL_ERROR); /** -- EXIT (FAILURE) -> **/
191-
#else
192-
strncat(domain, _(em_unknown), DOMAINLEN);
193194
#endif
195+
196+
/**
197+
** some oses (BSD) return empty domain
198+
**/
199+
if (! *domain)
200+
strncat(domain, _(em_unknown), DOMAINLEN);
194201
/**
195202
** Now the name structure surely IS initialized
196203
**/

0 commit comments

Comments
 (0)