summaryrefslogtreecommitdiff
path: root/libpiano
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-01-18 15:27:28 +0100
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-01-18 15:27:28 +0100
commita5b1ca01c3e17b4113d54003b2d6f797d54b17a2 (patch)
tree6b8b51091ea69b45b23d27a398d15b0f5298b8cf /libpiano
parent994c61fb0da9628161c3ebaab533b9e715d284be (diff)
downloadpianobar-a5b1ca01c3e17b4113d54003b2d6f797d54b17a2.tar.gz
pianobar-a5b1ca01c3e17b4113d54003b2d6f797d54b17a2.tar.bz2
pianobar-a5b1ca01c3e17b4113d54003b2d6f797d54b17a2.zip
piano: Safe routeid generation
Use modulo instead of >> (shift right) to get seven digits.
Diffstat (limited to 'libpiano')
-rw-r--r--libpiano/src/main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c
index 42c51bf..a71fbba 100644
--- a/libpiano/src/main.c
+++ b/libpiano/src/main.c
@@ -61,17 +61,16 @@ void PianoFree (void *ptr, size_t size) {
}
}
-/* initialize piano handle, set up curl handle and settings; note: you
- * _must_ init curl and libxml2 using curl_global_init (CURL_GLOBAL_SSL)
- * and xmlInitParser (), you also _must_ cleanup their garbage on your own!
+/* initialize piano handle, set up curl handle and settings; note: _you_ have
+ * to init curl and libxml2 using curl_global_init (CURL_GLOBAL_SSL) and
+ * xmlInitParser (), _you_ also have to cleanup their garbage on your own!
* @param piano handle
* @return nothing
*/
void PianoInit (PianoHandle_t *ph) {
memset (ph, 0, sizeof (*ph));
ph->curlHandle = curl_easy_init ();
- /* FIXME: 64-bit may make this hack useless */
- snprintf (ph->routeId, sizeof (ph->routeId), "%07liP", time (NULL)>>8);
+ snprintf (ph->routeId, sizeof (ph->routeId), "%07liP", time (NULL) % 10000000);
curl_easy_setopt (ph->curlHandle, CURLOPT_USERAGENT, PACKAGE_STRING);
curl_easy_setopt (ph->curlHandle, CURLOPT_CONNECTTIMEOUT, 60);
curl_easy_setopt (ph->curlHandle, CURLOPT_TIMEOUT, 60);