Problem with sethostname() ??

Suresh babu V. (suresh.babu@wipro.com)
Thu, 10 Oct 2002 12:13:28 +0530


This is a multi-part message in MIME format.

------=_NextPartTM-000-db2acf37-6c1c-4dcb-9550-4c4ebac6c78c
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,

While attempting for some testing with sethostname() call, I got
this problem . As explained in the man page the sethostname call is
failing(ret val = -1 & errno = EFAULT(14)) for invalid address and valid
length. But the problem is after running the following test, hostname is
getting reset to NULL. I tested in both 2.4 & 2.5 kernels.

Any comments on this??

----------------------------------
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

main()
{
int ret, errno;
unsigned short int len;
char host[50]="tmphost"; /* hostname max size is 64 */
errno = 0;
len = sizeof(host);

/* valid length and invalid address, expected err is EFAULT */
ret = sethostname((void *)-1, len);
printf("return val : %d, err no: %d \n",ret,errno);

}
-------------------------------------------------

I saw the code of sys_sethostname() function (sys.c) , in which
copy_from_user() is being called. I would like to know is it required to
validate the name argument before calling copy_from_user() to avoid such
problems.

We could expect similar problem in setdomainname() also in which
same sort of code is used.

PS : Please CC me your replies as I havn't subscribed to the list.

Thanks,
Suresh.

------=_NextPartTM-000-db2acf37-6c1c-4dcb-9550-4c4ebac6c78c
Content-Type: text/plain;
name="Wipro_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Wipro_Disclaimer.txt"

**************************Disclaimer**************************************************

Information contained in this E-MAIL being proprietary to Wipro Limited is 'privileged'
and 'confidential' and intended for use only by the individual or entity to which it is
addressed. You are notified that any use, copying or dissemination of the information
contained in the E-MAIL in any manner whatsoever is strictly prohibited.

****************************************************************************************

------=_NextPartTM-000-db2acf37-6c1c-4dcb-9550-4c4ebac6c78c--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/