mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	Fix server id generator bug. v4.0.254
This commit is contained in:
		
							parent
							
								
									7b23a42139
								
							
						
					
					
						commit
						febd45d514
					
				
					 3 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -193,11 +193,15 @@ srs_error_t SrsLatestVersion::start()
 | 
			
		|||
        uuid_t uuid;
 | 
			
		||||
        uuid_generate_time(uuid);
 | 
			
		||||
 | 
			
		||||
        char buf[32];
 | 
			
		||||
        // Must reserve last 1 byte for the trailing '\0', because we expect the size of uuid string is 32 bytes.
 | 
			
		||||
        char buf[32 + 1];
 | 
			
		||||
        srs_assert(16 == sizeof(uuid_t));
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < 16; i++) {
 | 
			
		||||
            snprintf(buf + i * 2, sizeof(buf), "%02x", uuid[i]);
 | 
			
		||||
            int r0 = snprintf(buf + i * 2, sizeof(buf) - i * 2, "%02x", uuid[i]);
 | 
			
		||||
            srs_assert(r0 > 0 && r0 < sizeof(buf) - i * 2);
 | 
			
		||||
        }
 | 
			
		||||
        server_id_ = string(buf, sizeof(buf));
 | 
			
		||||
        server_id_ = buf;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return trd_->start();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue