Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ AC_ARG_ENABLE([bci_support],
esac],[bci_support=false])
AM_CONDITIONAL(BCI_SUPPORT, test x"$bci_support" = x"true")

# Checks for DHCP_VoiceOptions_support
AC_ARG_ENABLE([dhcpVoiceOptions_support],
[ --enable-dhcpVoiceOptions_support=val Turn on dhcp_VoiceOptions, val=true or false],
[case "${enableval}" in
yes) dhcp_voiceOptions_support=true ;;
no) dhcp_voiceOptions_support=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-dhcpVoiceOptions_support]) ;;
esac],[dhcp_voiceOptions_support=false])
AM_CONDITIONAL(DHCP_VOICE_OPTIONS_SUPPORT, test x"$dhcp_voiceOptions_support" = x"true")
Comment on lines +235 to +239
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent variable naming: The configure option is named "dhcpVoiceOptions_support" in the AC_ARG_ENABLE but the internal variable is named "dhcp_voiceOptions_support" (note the underscore positions differ). This inconsistency could lead to confusion during debugging or when modifying the build system. The variable naming should be consistent throughout.

Suggested change
yes) dhcp_voiceOptions_support=true ;;
no) dhcp_voiceOptions_support=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-dhcpVoiceOptions_support]) ;;
esac],[dhcp_voiceOptions_support=false])
AM_CONDITIONAL(DHCP_VOICE_OPTIONS_SUPPORT, test x"$dhcp_voiceOptions_support" = x"true")
yes) dhcpVoiceOptions_support=true ;;
no) dhcpVoiceOptions_support=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-dhcpVoiceOptions_support]) ;;
esac],[dhcpVoiceOptions_support=false])
AM_CONDITIONAL(DHCP_VOICE_OPTIONS_SUPPORT, test x"$dhcpVoiceOptions_support" = x"true")

Copilot uses AI. Check for mistakes.

# Check ra_monitor_support
AM_CONDITIONAL([RA_MONITOR_SUPPORT], [test "$RA_MONITOR_SUPPORT" = "yes"])

Expand Down
2 changes: 1 addition & 1 deletion source/DHCPClientUtils/DHCPv4Client/dhcp_client_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int check_proc_entry_for_pid (char * name, char * args)
int64_t pid;
int rval = 0;
char processName[BUFLEN_256];
char cmdline[512] = {0};
char cmdline[1024] = {0};
char filename[BUFLEN_256];
char status = 0;

Expand Down
32 changes: 19 additions & 13 deletions source/DHCPClientUtils/DHCPv4Client/dhcpv4_interface_udhcpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static int udhcpc_get_req_options (char * buff, dhcp_opt_list * req_opt_list)
* @param[in] ascii_len Length of the output buffer.
* @return 0 on success, -1 on failure.
*/

static int hex_to_ascii(const char *hex, char *ascii, size_t ascii_len)
{
if (hex == NULL || ascii == NULL || ascii_len == 0)
Expand Down Expand Up @@ -139,27 +140,32 @@ static int udhcpc_get_send_options (char * buff, dhcp_opt_list * send_opt_list)
return SUCCESS;
}

char args [BUFLEN_128] = {0};
char args [BUFLEN_512] = {0};
while ((send_opt_list != NULL) && (send_opt_list->dhcp_opt_val != NULL))
{
memset (&args, 0, BUFLEN_128);
memset (&args, 0, BUFLEN_512);
if (send_opt_list->dhcp_opt == DHCPV4_OPT_60)
{
/* Option 60 - Vendor Class Identifier has udhcp cmd line arg "-V <option-str>"
* If this option is not set with '-V' then udhcpc will add a default vendor class option with its name and version.
* So we need to set this option with '-V' with ACSII string.
*/

char ascii_val[BUFLEN_128] = {0};
if( hex_to_ascii(send_opt_list->dhcp_opt_val, ascii_val, sizeof(ascii_val)) == 0)
if(0== strncmp(send_opt_list->dhcp_opt_val,"pktc2.0:",strlen("pktc2.0:")))
{

snprintf(args, BUFLEN_128, "-V %s ", ascii_val);
snprintf(args, BUFLEN_512, "-V %s ", send_opt_list->dhcp_opt_val);
}
else
{
/* Option 60 - Vendor Class Identifier has udhcp cmd line arg "-V <option-str>"
* If this option is not set with '-V' then udhcpc will add a default vendor class option with its name and version.
* So we need to set this option with '-V' with ACSII string.
*/
char ascii_val[BUFLEN_128] = {0};
if( hex_to_ascii(send_opt_list->dhcp_opt_val, ascii_val, sizeof(ascii_val)) == 0)
{
snprintf(args, BUFLEN_128, "-V %s ", ascii_val);
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer size is increased from BUFLEN_128 to BUFLEN_512 for args in multiple locations, but only BUFLEN_128 is still used in the snprintf call at line 162. This creates an inconsistency where the buffer is declared with BUFLEN_512 but written with BUFLEN_128 as the size limit, which could lead to confusion and potential buffer overflow if the code is modified later. The snprintf size should match the actual buffer size.

Suggested change
snprintf(args, BUFLEN_128, "-V %s ", ascii_val);
snprintf(args, BUFLEN_512, "-V %s ", ascii_val);

Copilot uses AI. Check for mistakes.
}
}
Comment on lines +149 to 164
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The special case handling for Option 60 when the value starts with "pktc2.0:" passes the value directly without hex-to-ASCII conversion. However, the comment at lines 155-157 states that the original behavior is to prevent udhcpc from adding a default vendor class option. This creates an inconsistency: for voice interfaces (pktc2.0:), the value is passed as-is (presumably already in ASCII), while for other interfaces, hex values are converted to ASCII. The code should validate that pktc2.0: values are in the expected format and document why they bypass the hex-to-ASCII conversion.

Copilot uses AI. Check for mistakes.
}
else
{
snprintf (args, BUFLEN_128, "-x 0x%02X:%s ", send_opt_list->dhcp_opt, send_opt_list->dhcp_opt_val);
snprintf (args, BUFLEN_512, "-x 0x%02X:%s ", send_opt_list->dhcp_opt, send_opt_list->dhcp_opt_val);
}
send_opt_list = send_opt_list->next;
strcat (buff,args);
Expand Down Expand Up @@ -277,7 +283,7 @@ pid_t start_dhcpv4_client(char *interfaceName, dhcp_opt_list *req_opt_list, dhcp
}


char buff [BUFLEN_512] = {0};
char buff [BUFLEN_1024] = {0};
udhcpc_args_generator(buff,interfaceName, req_opt_list, send_opt_list);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,19 @@ typedef unsigned long ULONG;

//DHCPv4 Options
#define DHCPV4_OPT_2 2 // Time Offset
#define DHCPV4_OPT_4 4 // Time Server
#define DHCPV4_OPT_7 7 // Log Server
#define DHCPV4_OPT_42 42 // NTP Server Addresses
#define DHCPV4_OPT_43 43 // Vendor Specific Information
#define DHCPV4_OPT_54 54 // DHCP Server Identifier
#define DHCPV4_OPT_58 58 // DHCP Renewal (T1) Time
#define DHCPV4_OPT_59 59 // DHCP Rebinding (T2) Time
#define DHCPV4_OPT_60 60 // Class Identifier
#define DHCPV4_OPT_61 61 // Client Identifier
#define DHCPV4_OPT_99 99 // TFTP Server IP Address
#define DHCPV4_OPT_100 100 // IEEE 1003.1 TZ String
#define DHCPV4_OPT_122 122 // CableLabs Client Configuration
#define DHCPV4_OPT_123 123 // Time zone offset
#define DHCPV4_OPT_125 125 // Vendor-Identifying Vendor-Specific Information
#define DHCPV4_OPT_242 242 // Private Use
#define DHCPV4_OPT_243 243 // Private Use
Expand Down
3 changes: 3 additions & 0 deletions source/DHCPMgrUtils/CustomOptions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ lib_LTLIBRARIES = libcustomoptions.la
# Source files for the library
libcustomoptions_la_SOURCES = dhcpmgr_custom_options.c

if DHCP_VOICE_OPTIONS_SUPPORT
libcustomoptions_la_SOURCES += dhcpmgr_voice_custom_options.c
endif
# Include directories
libcustomoptions_la_CPPFLAGS = -I$(top_srcdir)/source/DHCPServerUtils/utils/include \
-I$(top_srcdir)/source/DHCPMgrInterface/include
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,4 @@ static int set_mta_config(const char *OptionValue, char *version)
}
return 0;
}
#endif
#endif
Loading