lusis/pam_stormpath — pull request #1 by jlogday (2013-06-23 15:09:00+00:00)
Title: Refactoring

1. This is my first PR, please be gentle.
2. I am also still coming up to speed on git, so I've probably not followed all of the normal conventions
3. I didn't have vim setup correctly wrt tabs, so the whitespace is probably a bit mangled.

# Minor Changes
* make now produces a `pam_stormpath` executable, which may be used for testing
* added a `.gitignore` file
* changed `cencode.c` to _not_ append a newline to the end of the encoded string

# Bigger Changes
* b64enc.c
* Not enough memory was allocated for the encoded string, which caused an overrun into the state variable declared after it. Depending on the input, this could cause a segfault, or just cause the output to have garbage at the end.
* Removed the temporary variable and extra allocation.
* This still needs error handling; the b64enc function should be changed to return an int so that the caller can handle the error.
* config.c
* Removed the sp_params struct and temporary variables.
* Changed the parser to use `strtok_r`
* Added a `free(line)` call after parsing the config file.
* req.c
* Changed `spid`, `spsecret`, and `spapplication` initializations to `NULL`. The `sp_config` function will allocate the memory for these variables.
* Changed `creds`, `spurl`, `auth_clear`, and `auth_data` to be statically allocated rather than using `malloc`. The maximum sizes for these variables are arbitrary but should be acceptable.
* Changed `sprintf` to `snprintf` to avoid overruns.
* Free the dynamically-allocated variables: `spid`, `spsecret`, `spapplication`, `auth_b64`