mirror of
				https://github.com/Tha14/toxic.git
				synced 2025-11-04 13:46:52 +01:00 
			
		
		
		
	fix issue where log file cannot be created due to invalid name/path
This commit is contained in:
		@@ -42,6 +42,9 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log)
 | 
			
		||||
    if (!log->log_on)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (!valid_nick(name))
 | 
			
		||||
        name = UNKNOWN_NAME;
 | 
			
		||||
 | 
			
		||||
    char *user_config_dir = get_user_config_dir();
 | 
			
		||||
    int path_len = strlen(user_config_dir) + strlen(CONFIGDIR) + strlen(name); 
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -202,6 +202,7 @@ int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2)
 | 
			
		||||
/* Returns 1 if nick is valid, 0 if not. A valid toxic nick:
 | 
			
		||||
      - cannot be empty
 | 
			
		||||
      - cannot start with a space
 | 
			
		||||
      - must not contain a forward slash (for logfile naming purposes)
 | 
			
		||||
      - must not contain contiguous spaces */
 | 
			
		||||
int valid_nick(uint8_t *nick)
 | 
			
		||||
{
 | 
			
		||||
@@ -213,6 +214,8 @@ int valid_nick(uint8_t *nick)
 | 
			
		||||
    for (i = 0; nick[i]; ++i) {
 | 
			
		||||
        if (nick[i] == ' ' && nick[i+1] == ' ')
 | 
			
		||||
            return 0;
 | 
			
		||||
        if (nick[i] == '/')
 | 
			
		||||
            return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user