Skip to content

Commit c9b2f6e

Browse files
rdmarkandylemin
authored andcommitted
afpd: check that username is a string before assigning in log_dircache_stat()
The validation of AFPobj->username in this ternary statement always evaluates as true because the username struct member is defined as a char array with fixed width, and therefore always has a valid pointer Instead, we check that the first char in the array is non-null to validate that it is actually a string
1 parent 83d16d2 commit c9b2f6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

etc/afpd/dircache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ void log_dircache_stat(void)
629629
/* Get username from AFPobj if available */
630630
extern AFPObj *AFPobj;
631631
const char *username = (AFPobj
632-
&& AFPobj->username) ? AFPobj->username : "unknown";
632+
&& AFPobj->username[0]) ? AFPobj->username : "unknown";
633633
LOG(log_info, logtype_afpd,
634634
"dircache statistics: (user: %s) "
635635
"entries: %lu, lookups: %llu, hits: %llu (%.1f%%), misses: %llu, "

0 commit comments

Comments
 (0)