Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit aeb0edee69e202b220df96a5174ebf925e42f1d7 1 parent d429fc7
David Moreno Montero authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 examples/oterm/oterm_handler.c
6 examples/oterm/oterm_handler.c
View
@@ -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);
close(fd);
+ 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++){
oterm->uuid[i]=random_chars[rand()%sizeof(random_chars)];
Please sign in to comment.
Something went wrong with that request. Please try again.