Perform basic sanity checks in signUp handler

This fixes Issue #69 recorded in the oBIX github repo. The root cause is
that if the href in the signUp device is an empty string, dirname returns
"." and such string should NOT be freed by the application or otherwise
it segfaults.

Before any node is added to the global DOM tree, sanity checks should have
been properly done on its href. Furthermore, as for the signUp handler, all
devices should go to the device lobby.

Valgrind tests passed when trying to sign up a device with following
invalid hrefs:
 . ""
 . " " or "		"
 . "." or ". " or ".."
 . "/"
 . "//"
 . "/."
 . "/obix/outsideofdevicelobby"

Instead of segfaults, oBIX server return an error contract gracefully.
Sure! A piece of cake :-)

Thanks Tyler!

How did I do? 1-click feedback: https://secure.teamhively.com/welcome/rate/7672
________________________________
From: obix-devel-bounces@onedc.com [obix-devel-bounces@onedc.com] on behalf of Tyler Watson [notifications@github.com]
Sent: Tuesday, October 14, 2014 4:30 PM
To: ONEDC/obix
Subject: Re: [Obix-devel] [obix] Perform basic sanity checks in signUp handler (#71)


In src/server/server.c:

> @@ -90,6 +92,14 @@ static err_msg_t server_err_msg[] = {
>               .type = OBIX_CONTRACT_ERR_UNSUPPORTED,
>               .msgs = "No input available from oBIX clients"
>       },
> +     [ERR_INVALID_HREF] = {
> +             .type = OBIX_CONTRACT_ERR_UNSUPPORTED,
> +             .msgs = "Invalid href from oBIX client's input document"
> +     },
> +     [ERR_ILLEGAL_HREF] = {
> +             .type = OBIX_CONTRACT_ERR_UNSUPPORTED,
> +             .msgs = "Illegal href outside of devices lobby"


English proof-read.

ERR_INVALID_HREF
ERR_ILLEGAL_HREF

There is an ambiguity between these two constants: What consitutes an "invalid href" as opposed to an "illegal href" when in English, they essentially mean the same thing? The messages here for any client reading them is confusing and not very helpful. My advice, I believe there should be a generic message for most sanity check failures that reads Provided input is invalid: <reason>.

Some helpful error messages in my mind would read:

  *   Provided input is invalid: href attribute does not exist - for missing or blank hrefs
  *   Provided input is invalid: invalid device href location - for href sanity check fails
  *   Provided input is invalid: provided device contract does not exist - for a blank input

—
Reply to this email directly or view it on GitHub<https://github.com/ONEDC/obix/pull/71/files#r18810863>.


The information contained in this email and any attachments may be confidential. This email and any attachments are also subject to copyright. No part of them may be reproduced, adapted or transmitted without the written permission of the copyright owner. If you are not the intended recipient, any use, interference with, disclosure or copying of this information is unauthorised and prohibited. If you have received this email in error, please immediately advise the sender by return email and delete the message from your system. All email communications to and from NEXTDC Limited are recorded for the purposes of archival and storage.