]> sourceware.org Git - lvm2.git/commitdiff
Fix create_temp_name to replace any '/' found in the hostname with '?'.
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 8 Jun 2011 08:49:53 +0000 (08:49 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 8 Jun 2011 08:49:53 +0000 (08:49 +0000)
There's a possibility someone will use the '/' in the hostname. Since we
generate a temporary file name (path) including the hostname, any '/' would
be ambiguous.

We can always set such hostname using 'sethostname' from unistd.h. But the
'hostname' command already includes the check and removes the '/' char.
However, some old versions still allow that.
See: https://bugzilla.redhat.com/show_bug.cgi?id=711445.

Since this is only a temporary name and the possibility of this error is
quite negligible, we don't need any complex escape sequence here, just a
simple char replace.

WHATS_NEW
lib/misc/lvm-file.c

index 7c14bc0996dbc5b4d3986d3b75cdefb28a22a891..01032aed6562ec84851bd85747aff847e51d229f 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Fix create_temp_name to replace any '/' found in the hostname with '?'.
   Always use append to file in lvmdump (selinux policy - no file truncation).
   Propagate test mode to clvmd to skip activation and changes to held locks.
   Defer writing PV labels to vg_write.
index f577840bfaf95310a81d93b0153e7e95cabc1a2c..6e50cf81496fed267d688c93b0094abe484fa9fd 100644 (file)
@@ -35,6 +35,7 @@ int create_temp_name(const char *dir, char *buffer, size_t len, int *fd,
        int i, num;
        pid_t pid;
        char hostname[255];
+       char *p;
        struct flock lock = {
                .l_type = F_WRLCK,
                .l_whence = 0,
@@ -48,6 +49,12 @@ int create_temp_name(const char *dir, char *buffer, size_t len, int *fd,
                log_sys_error("gethostname", "");
                strcpy(hostname, "nohostname");
        }
+       else {
+               /* Replace any '/' with '?' found in the hostname. */
+               p = hostname;
+               while ((p = strchr(p, '/')))
+                       *p = '?';
+       }
 
        for (i = 0; i < 20; i++, num++) {
 
This page took 0.048908 seconds and 5 git commands to generate.