Browse files

Fix when can open kernel uuid generator, but returns invalid data.

Not that should happend, but as compiler forces us to use the read(...) result.
  • Loading branch information...
1 parent d429fc7 commit aeb0edee69e202b220df96a5174ebf925e42f1d7 @davidmoreno committed Nov 30, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 examples/oterm/oterm_handler.c
6 examples/oterm/oterm_handler.c
@@ -234,10 +234,12 @@ process *oterm_new(oterm_data *data, oterm_session *session, const char *usernam
int fd=open("/proc/sys/kernel/random/uuid", O_RDONLY);
if (fd>=0){
- read(fd, oterm->uuid, sizeof(oterm->uuid)-1);
+ int r=read(fd, oterm->uuid, sizeof(oterm->uuid)-1);
+ if (r!=sizeof(oterm->uuid)-1) // So we will use the pseudo random generator.
+ fd=-1;
- else{
+ if (fd<0){
const char random_chars[]="0123456789abcdef-";
for (i=0;i<sizeof(oterm->uuid)-1;i++){

0 comments on commit aeb0ede

Please sign in to comment.