Skip to contentSkip to conversation

r5531 made x509 certs not loadable [PATCH]

Qemu-devel Henrik Holst 2 participants 2 messages Nov 12, 2008

lore
Share & tools
lore
#0 lore raw

The patch in r5531 which replaced a bunch of strncpy with pstrcpy causes the x509 credentials from the -vnc parameter to be one character shorter than entered meaning that there is currently no way to enter x509 certificates...

The attached patch fixes this. Also the path[len]='\0' is unnecessary now that pstrcpy is used. The problem was that the previous strncpy was called correctly which the r5531 patch didn't think. And due to how the code is a memcpy could probably be used instead...

vnc.c +1 -2
Index: vnc.c
===================================================================
@@ -2338,8 +2338,7 @@
 		int len = end ? end-(start+1) : strlen(start+1);
 		char *path = qemu_malloc(len+1);
 
-                pstrcpy(path, len, start + 1);
-		path[len] = '\0';
+                pstrcpy(path, len + 1, start + 1);
 		VNC_DEBUG("Trying certificate path '%s'\n", path);
 		if (vnc_set_x509_credential_dir(vs, path) < 0) {
 		    fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);

/Henrik Holst
Witsbits AB

vnc.c +1 -2
Index: vnc.c
===================================================================
@@ -2338,8 +2338,7 @@
 		int len = end ? end-(start+1) : strlen(start+1);
 		char *path = qemu_malloc(len+1);
 
-                pstrcpy(path, len, start + 1);
-		path[len] = '\0';
+                pstrcpy(path, len + 1, start + 1);
 		VNC_DEBUG("Trying certificate path '%s'\n", path);
 		if (vnc_set_x509_credential_dir(vs, path) < 0) {
 		    fprintf(stderr, "Failed to find x509 certificates/keys in %s\n", path);
#1 lore raw

2008/11/12 Henrik Holst <[email protected]>:

Quoted 9 lines

The patch in r5531 which replaced a bunch of strncpy with pstrcpy causes the x509 credentials from the -vnc parameter to be one character shorter than entered meaning that there is currently no way to enter x509 certificates...

The attached patch fixes this. Also the path[len]='\0' is unnecessary now that pstrcpy is used. The problem was that the previous strncpy was called correctly which the r5531 patch didn't think. And due to how the code is a memcpy could probably be used instead...

Thanks for spotting. I made it a qemu_strndup instead because that's basically what's being implemented here (to be exact it could be a memdup() here because the length is already known). Please test.

Cheers