To prevent from overwriting requested data if the request is duplicated.
Change-Id: I0c71c439a8e15d16b1f56bbd484dcb789cf136ba
* limitations under the License.
*
*/
* limitations under the License.
*
*/
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
struct packet *packet;
struct request_item *item;
char *filename;
struct packet *packet;
struct request_item *item;
char *filename;
int len;
if (!handle || handle->state != CREATED) {
int len;
if (!handle || handle->state != CREATED) {
group = DEFAULT_ICON_GROUP;
}
group = DEFAULT_ICON_GROUP;
}
- len = strlen(outfile) + strlen(".desc") + 1;
+ len = strlen(outfile) + strlen(".desc") + 1 + 30; /* 30 == strlen(tv.tv_sec) + strlen(tv.tv_usec) + 10 (reserved) */
filename = malloc(len);
if (!filename) {
ErrPrint("Heap: %s\n", strerror(errno));
return -ENOMEM;
}
filename = malloc(len);
if (!filename) {
ErrPrint("Heap: %s\n", strerror(errno));
return -ENOMEM;
}
- snprintf(filename, len, "%s.desc", outfile);
+ if (gettimeofday(&tv, NULL) != 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ tv.tv_sec = rand();
+ tv.tv_usec = rand();
+ }
+
+ ret = snprintf(filename, len, "%s.%lu.%lu.desc", outfile, tv.tv_sec, tv.tv_usec);
+ if (ret < 0) {
+ ErrPrint("snprintf: %s\n", strerror(errno));
+ goto out;
+ }
ret = shortcut_icon_desc_save(handle->desc, filename);
if (ret < 0) {
ret = shortcut_icon_desc_save(handle->desc, filename);
if (ret < 0) {
Name: libshortcut
Summary: Shortcut add feature supporting library
Name: libshortcut
Summary: Shortcut add feature supporting library
Release: 0
Group: HomeTF/Framework
License: Apache License
Release: 0
Group: HomeTF/Framework
License: Apache License