[patch] various bugs and strncpy abuse followup

Tito farmatito at tiscali.it
Wed Jun 7 07:09:27 UTC 2006


On Wednesday 7 June 2006 00:34, you wrote:
> After the very helpful feedback and the continual searching for bugs, I
> have expanded my patch associated to various bugs all over busybox.
> 
> This patchset has gotten bigger. So I have taken to splitting them up by
> file and annotating them in patch. I hope that is useful. Let me know if
> there is some way I can make this easier to go over or help with
> acceptance.
> 
> Feel free to address each patch seperately in responding. I would not be
> surprised at all if I accidentally introduced regressions. I have not
> yet tried running the unit testing. But I have attempted to understand
> why each bug is a bug and addressed it according to its severity.
> 
> I appreciate any attention you might give this work.
> 
> E
Hi, in the vlock patch:

I can't say due to my limited knowledge if it makes sense
to have error messages in signal handlers, but nonetheless
they could be shorter. ;-)

 static void release_vt(int signo)
 {
-	if (!o_lock_all)
-		ioctl(vfd, VT_RELDISP, 1);
-	else
-		ioctl(vfd, VT_RELDISP, 0);
+	if (!o_lock_all) {
+		if (ioctl(vfd, VT_RELDISP, 1) < 0)
+			bb_error_msg("failed in attempting to release the display");
+	} else
+		if (ioctl(vfd, VT_RELDISP, 0) < 0)
+			bb_error_msg("failed in attempting to release the display");
 }
 

static void release_vt(int signo)
 {
	if (ioctl(vfd, VT_RELDISP, (!o_lock_all) ? 1 : 0) < 0) {
		bb_perror_msg("VT_RELDISP");
	}
}

or maybe

static void release_vt(int signo)
 {
	if (ioctl(vfd, VT_RELDISP, (!o_lock_all)) < 0) {
		bb_perror_msg("VT_RELDISP");
	}
}


 static void acquire_vt(int signo)
 {
-	ioctl(vfd, VT_RELDISP, VT_ACKACQ);
+	if (ioctl(vfd, VT_RELDISP, VT_ACKACQ) < 0)
+		bb_error_msg("failed in attempting to release the display");
 }
 
 static void acquire_vt(int signo)
 {
	if (ioctl(vfd, VT_RELDISP, VT_ACKACQ) < 0)
		bb_perror_msg("VT_ACKACQ");
 }

 static void restore_terminal(void)
 {
-	ioctl(vfd, VT_SETMODE, &ovtm);
+	if (ioctl(vfd, VT_SETMODE, &ovtm) < 0)
+		bb_error_msg("failed to set the mode of the active vt");
 	tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
 }
 
 static void restore_terminal(void)
 {
	if (ioctl(vfd, VT_SETMODE, &ovtm) < 0)
		bb_perror_msg("VT_SETMODE");
 	tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
 }
@@ -106,7 +110,8 @@
 	vtm.mode = VT_PROCESS;
 	vtm.relsig = SIGUSR1;
 	vtm.acqsig = SIGUSR2;
-	ioctl(vfd, VT_SETMODE, &vtm);
+	if (ioctl(vfd, VT_SETMODE, &vtm) < 0)
+        bb_perror_msg_and_die("VT_SETMODE");

Ciao,
Tito



More information about the busybox mailing list