Skip to content

Commit a321c37

Browse files
mibgroup: notification: avoid potential null dereference
The pointer var_val was utilized before check against NULL. Signed-off-by: Maksim Korotkov <[email protected]>
1 parent c4298a9 commit a321c37

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

agent/mibgroup/notification/snmpNotifyFilterProfileTable.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ write_snmpNotifyFilterProfileRowStatus(int action,
394394
static struct snmpNotifyFilterProfileTable_data *StorageDel;
395395
size_t newlen = name_len - table_offset;
396396
static int old_value;
397-
int set_value = *((long *) var_val);
397+
int set_value = var_val ? *((long *) var_val) : RS_NONEXISTENT;
398398
netsnmp_variable_list *vars;
399399

400400

@@ -530,16 +530,15 @@ write_snmpNotifyFilterProfileRowStatus(int action,
530530
/*
531531
* XXX: ack, and if it is NULL?
532532
*/
533-
} else if (set_value != RS_DESTROY) {
533+
} else if (set_value != RS_DESTROY && set_value != RS_NONEXISTENT) {
534534
/*
535535
* set the flag?
536536
*/
537537
if (StorageTmp == NULL)
538538
return SNMP_ERR_GENERR; /* should never ever get here */
539539

540540
old_value = StorageTmp->snmpNotifyFilterProfileRowStatus;
541-
StorageTmp->snmpNotifyFilterProfileRowStatus =
542-
*((long *) var_val);
541+
StorageTmp->snmpNotifyFilterProfileRowStatus = set_value;
543542
} else {
544543
/*
545544
* destroy... extract it for now

agent/mibgroup/notification/snmpNotifyTable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ write_snmpNotifyRowStatus(int action,
523523
static struct snmpNotifyTable_data *StorageDel;
524524
size_t newlen = name_len - snmpNotifyTable_offset;
525525
static int old_value;
526-
int set_value = *((long *) var_val);
526+
int set_value = var_val ? *((long *) var_val) : RS_NONEXISTENT;
527527
static netsnmp_variable_list *vars, *vp;
528528

529529
DEBUGMSGTL(("snmpNotifyTable",
@@ -645,15 +645,15 @@ write_snmpNotifyRowStatus(int action,
645645
if (StorageNew != NULL) {
646646
snmpNotifyTable_add(StorageNew);
647647
}
648-
} else if (set_value != RS_DESTROY) {
648+
} else if (set_value != RS_DESTROY && set_value != RS_NONEXISTENT) {
649649
/*
650650
* set the flag?
651651
*/
652652
if (StorageTmp == NULL)
653653
return SNMP_ERR_GENERR; /* should never ever get here */
654654

655655
old_value = StorageTmp->snmpNotifyRowStatus;
656-
StorageTmp->snmpNotifyRowStatus = *((long *) var_val);
656+
StorageTmp->snmpNotifyRowStatus = set_value;
657657
} else {
658658
/*
659659
* destroy... extract it for now

0 commit comments

Comments
 (0)